Committed by
Gerrit Code Review
Updating onos-maven-plugin to use localRepository from Maven
rather than explicit path Also, updating root pom.xml to point to the version and temporarily build the plugin Change-Id: I1a6cdaf3d384dff77cd9b4566a8c46707b789308
Showing
2 changed files
with
18 additions
and
11 deletions
... | @@ -39,6 +39,7 @@ | ... | @@ -39,6 +39,7 @@ |
39 | <description>Open Network Operating System root project</description> | 39 | <description>Open Network Operating System root project</description> |
40 | 40 | ||
41 | <modules> | 41 | <modules> |
42 | + <module>tools/package/maven-plugin</module> | ||
42 | <module>utils</module> | 43 | <module>utils</module> |
43 | <module>core</module> | 44 | <module>core</module> |
44 | <module>web</module> | 45 | <module>web</module> |
... | @@ -578,7 +579,7 @@ | ... | @@ -578,7 +579,7 @@ |
578 | <plugin> | 579 | <plugin> |
579 | <groupId>org.onosproject</groupId> | 580 | <groupId>org.onosproject</groupId> |
580 | <artifactId>onos-maven-plugin</artifactId> | 581 | <artifactId>onos-maven-plugin</artifactId> |
581 | - <version>1.3</version> | 582 | + <version>1.4-SNAPSHOT</version> |
582 | <executions> | 583 | <executions> |
583 | <execution> | 584 | <execution> |
584 | <id>cfg</id> | 585 | <id>cfg</id> | ... | ... |
... | @@ -18,6 +18,7 @@ package org.onosproject.maven; | ... | @@ -18,6 +18,7 @@ package org.onosproject.maven; |
18 | import com.google.common.io.ByteStreams; | 18 | import com.google.common.io.ByteStreams; |
19 | import org.apache.commons.configuration.ConfigurationException; | 19 | import org.apache.commons.configuration.ConfigurationException; |
20 | import org.apache.commons.configuration.XMLConfiguration; | 20 | import org.apache.commons.configuration.XMLConfiguration; |
21 | +import org.apache.maven.artifact.repository.ArtifactRepository; | ||
21 | import org.apache.maven.plugin.AbstractMojo; | 22 | import org.apache.maven.plugin.AbstractMojo; |
22 | import org.apache.maven.plugin.MojoExecutionException; | 23 | import org.apache.maven.plugin.MojoExecutionException; |
23 | import org.apache.maven.plugins.annotations.Component; | 24 | import org.apache.maven.plugins.annotations.Component; |
... | @@ -57,7 +58,6 @@ public class OnosAppMojo extends AbstractMojo { | ... | @@ -57,7 +58,6 @@ public class OnosAppMojo extends AbstractMojo { |
57 | private static final String FEATURES_XML = "features.xml"; | 58 | private static final String FEATURES_XML = "features.xml"; |
58 | 59 | ||
59 | private static final String MVN_URL = "mvn:"; | 60 | private static final String MVN_URL = "mvn:"; |
60 | - private static final String M2_REPOSITORY = ".m2/repository"; | ||
61 | private static final String M2_PREFIX = "m2"; | 61 | private static final String M2_PREFIX = "m2"; |
62 | 62 | ||
63 | private static final String SNAPSHOT = "-SNAPSHOT"; | 63 | private static final String SNAPSHOT = "-SNAPSHOT"; |
... | @@ -108,17 +108,20 @@ public class OnosAppMojo extends AbstractMojo { | ... | @@ -108,17 +108,20 @@ public class OnosAppMojo extends AbstractMojo { |
108 | @Parameter(defaultValue = "${project.description}") | 108 | @Parameter(defaultValue = "${project.description}") |
109 | protected String projectDescription; | 109 | protected String projectDescription; |
110 | 110 | ||
111 | + @Parameter(defaultValue = "${localRepository}") | ||
112 | + protected ArtifactRepository localRepository; | ||
113 | + | ||
111 | /** | 114 | /** |
112 | * Maven project | 115 | * Maven project |
113 | */ | 116 | */ |
114 | - @Component | 117 | + @Parameter(defaultValue = "${project}") |
115 | - private MavenProject project; | 118 | + protected MavenProject project; |
116 | 119 | ||
117 | /** | 120 | /** |
118 | * Maven project helper. | 121 | * Maven project helper. |
119 | */ | 122 | */ |
120 | @Component | 123 | @Component |
121 | - private MavenProjectHelper projectHelper; | 124 | + protected MavenProjectHelper projectHelper; |
122 | 125 | ||
123 | 126 | ||
124 | private File m2Directory; | 127 | private File m2Directory; |
... | @@ -135,7 +138,7 @@ public class OnosAppMojo extends AbstractMojo { | ... | @@ -135,7 +138,7 @@ public class OnosAppMojo extends AbstractMojo { |
135 | return; | 138 | return; |
136 | } | 139 | } |
137 | 140 | ||
138 | - m2Directory = new File(System.getProperty("user.home"), M2_REPOSITORY); | 141 | + m2Directory = new File(localRepository.getBasedir()); |
139 | stageDirectory = new File(dstDirectory, PACKAGE_DIR); | 142 | stageDirectory = new File(dstDirectory, PACKAGE_DIR); |
140 | featureVersion = projectVersion.replace(SNAPSHOT, ""); | 143 | featureVersion = projectVersion.replace(SNAPSHOT, ""); |
141 | projectPath = M2_PREFIX + "/" + artifactDir(projectGroupId, projectArtifactId, projectVersion); | 144 | projectPath = M2_PREFIX + "/" + artifactDir(projectGroupId, projectArtifactId, projectVersion); |
... | @@ -147,11 +150,14 @@ public class OnosAppMojo extends AbstractMojo { | ... | @@ -147,11 +150,14 @@ public class OnosAppMojo extends AbstractMojo { |
147 | getLog().info("Building ONOS application package for " + name + " (v" + version + ")"); | 150 | getLog().info("Building ONOS application package for " + name + " (v" + version + ")"); |
148 | artifacts.forEach(a -> getLog().debug("Including artifact: " + a)); | 151 | artifacts.forEach(a -> getLog().debug("Including artifact: " + a)); |
149 | 152 | ||
150 | - stageDirectory.mkdirs(); | 153 | + if (stageDirectory.exists() || stageDirectory.mkdirs()) { |
151 | - processAppXml(appFile); | 154 | + processAppXml(appFile); |
152 | - processFeaturesXml(featuresFile); | 155 | + processFeaturesXml(featuresFile); |
153 | - processArtifacts(); | 156 | + processArtifacts(); |
154 | - generateAppPackage(); | 157 | + generateAppPackage(); |
158 | + } else { | ||
159 | + throw new MojoExecutionException("Unable to create directory: " + stageDirectory); | ||
160 | + } | ||
155 | } | 161 | } |
156 | } | 162 | } |
157 | 163 | ... | ... |
-
Please register or login to post a comment