Juan Hernandez has uploaded a new change for review.
Change subject: build: JBoss modules plugin multiple repositories
......................................................................
build: JBoss modules plugin multiple repositories
The plugin that we use to build JBoss modules creates and attaches an
additional artifact using the "modules" classifier. This results in
file names ending in "modules.zip. For example, for the tools module the
name of the file is currently the following:
tools-3.4.0-SNAPSHOT-modules.zip
The same type of name is used for all the modules, and this complicates
deployment when the modules need to be deployed to different module
repositories, as it is difficult to determine the target repository
looking only at the file name.
This change adds a new parameter to the configuration of the plugin that
is used to add a prefix to the classifier. This parameter can be added
as follows:
<plugin>
<groupId>org.ovirt.engine</groupId>
<artifactId>jboss-modules-maven-plugin</artifactId>
<configuration>
<moduleRepository>tools</moduleRepository>
</configuration>
</plugin>
With this configuration the classifier will be "shared-modules" and the
resulting file name will be:
tools-3.4.0-SNAPSHOT-tools-modules.zip
This way all the files that should be added to a particular repository
can be easily located using the prefix. For example, to locate all the
files that whould go to the "tools" repository the following pattern
could be used:
*-tools-modules.zip
This patch also makes some formatting changes in the code of the module,
to avoid long lines.
Change-Id: Id9f242083df287d01170183ad092a4b2bccb38ad
Signed-off-by: Juan Hernandez <[email protected]>
---
M
build-tools-root/jboss-modules-maven-plugin/src/main/java/org/ovirt/engine/build/ModulesMojo.java
1 file changed, 67 insertions(+), 20 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/22/18222/1
diff --git
a/build-tools-root/jboss-modules-maven-plugin/src/main/java/org/ovirt/engine/build/ModulesMojo.java
b/build-tools-root/jboss-modules-maven-plugin/src/main/java/org/ovirt/engine/build/ModulesMojo.java
index 6707978..db2d5da 100644
---
a/build-tools-root/jboss-modules-maven-plugin/src/main/java/org/ovirt/engine/build/ModulesMojo.java
+++
b/build-tools-root/jboss-modules-maven-plugin/src/main/java/org/ovirt/engine/build/ModulesMojo.java
@@ -18,7 +18,11 @@
import org.codehaus.plexus.archiver.zip.ZipArchiver;
import org.codehaus.plexus.util.FileUtils;
-@Mojo(name = "jboss-modules", defaultPhase = LifecyclePhase.PACKAGE,
requiresDependencyCollection = ResolutionScope.COMPILE)
+@Mojo(
+ name = "jboss-modules",
+ defaultPhase = LifecyclePhase.PACKAGE,
+ requiresDependencyCollection = ResolutionScope.COMPILE
+)
public class ModulesMojo extends AbstractMojo {
/**
@@ -44,6 +48,19 @@
*/
@Parameter(property = "moduleSlot", required = false, defaultValue =
"main")
private String moduleSlot;
+
+ /**
+ * The destination repository for the module. This is a string that will be
+ * user as a prefix of the classifier of the artifact containing the
module.
+ * The purpose of this prefix is to make it easy to deploy the modules to
+ * different module repositories, thus the name. For example, if the name
of
+ * the artifact is {@code hello} and the repository is {@code shared} the
+ * generated artifact name will be {@code hello-shared-modules.zip}. This
+ * simplifies the task of finding all the artifacts that need to be
deployed
+ * to the {@code shared} module repository.
+ */
+ @Parameter(property = "moduleRepository", required = false)
+ private String moduleRepository;
/**
* The list of modules to generate.
@@ -80,14 +97,21 @@
if (!modulesDir.exists()) {
if (!modulesDir.mkdirs()) {
throw new MojoExecutionException(
- "Can't create target modules directory \"" +
- modulesDir.getAbsolutePath() + "\"");
+ "Can't create target modules directory \"" +
+ modulesDir.getAbsolutePath() + "\""
+ );
}
}
// Copy any content from the source modules directory to the modules
// directory:
- String sourcePath = "src" + File.separator + "main" + File.separator +
"modules";
+ String sourcePath =
+ "src" +
+ File.separator +
+ "main" +
+ File.separator +
+ "modules"
+ ;
File sourceDir = new File(project.getBasedir(), sourcePath);
getLog().info("Copying module resources to \"" + modulesDir + "\"");
if (sourceDir.exists()) {
@@ -96,9 +120,12 @@
}
catch (IOException exception) {
throw new MojoExecutionException(
- "Can't copy source modules directory \"" +
sourceDir.getAbsolutePath() + "\" " +
- "to target modules directory \"" +
modulesDir.getAbsolutePath() + "\"",
- exception);
+ "Can't copy source modules directory \"" +
+ sourceDir.getAbsolutePath() + "\" " +
+ "to target modules directory \"" +
+ modulesDir.getAbsolutePath() + "\"",
+ exception
+ );
}
}
@@ -107,9 +134,21 @@
createModule(module);
}
+ // Calculate the classifier of the additional artifact:
+ String modulesClassifier = "modules";
+ if (moduleRepository != null) {
+ modulesClassifier = moduleRepository + "-" + modulesClassifier;
+ }
+
// Create the archive containing all the contents of the modules
// directory:
- File modulesArchive = new File(targetDir,
project.getBuild().getFinalName() + "-modules.zip");
+ File modulesArchive = new File(
+ targetDir,
+ project.getBuild().getFinalName() +
+ "-" +
+ modulesClassifier +
+ ".zip"
+ );
ZipArchiver modulesArchiver = new ZipArchiver();
modulesArchiver.setDestFile(modulesArchive);
modulesArchiver.addDirectory(modulesDir);
@@ -119,8 +158,10 @@
}
catch (Exception exception) {
throw new MojoExecutionException(
- "Can't generate modules archive \"" +
modulesArchive.getAbsolutePath() + "\"",
- exception);
+ "Can't generate modules archive \"" +
+ modulesArchive.getAbsolutePath() + "\"",
+ exception
+ );
}
// Attach the generated zip file containing the modules as an
@@ -138,12 +179,14 @@
if (!slotDir.exists()) {
if (!slotDir.mkdirs()) {
throw new MojoExecutionException(
- "Can't create module directory \"" +
- slotDir.getAbsolutePath() + "\"");
+ "Can't create module directory \"" +
+ slotDir.getAbsolutePath() + "\""
+ );
}
}
- // Find the dependency with the same group and artifact id that the
module:
+ // Find the dependency with the same group and artifact id that the
+ // module:
Artifact matchingArtifact = null;
if (module.matches(project.getArtifact())) {
matchingArtifact = project.getArtifact();
@@ -157,16 +200,19 @@
}
if (matchingArtifact == null) {
throw new MojoExecutionException(
- "Can't find dependency matching artifact id \"" +
module.getArtifactId() + "\" " +
- "and group id \"" + module.getGroupId() + "\"");
+ "Can't find dependency matching artifact id \"" +
+ module.getArtifactId() + "\" " +
+ "and group id \"" + module.getGroupId() + "\""
+ );
}
// Copy the artifact to the slot directory:
File artifactFrom = matchingArtifact.getFile();
if (artifactFrom == null) {
throw new MojoExecutionException(
- "Can't find file for artifact id \"" +
module.getArtifactId() + "\" " +
- "and group id \"" + module.getGroupId() + "\"");
+ "Can't find file for artifact id \"" + module.getArtifactId() +
+ "\" and group id \"" + module.getGroupId() + "\""
+ );
}
File artifactTo = new File(slotDir, module.getResourcePath());
getLog().info("Copying artifact to \"" + artifactTo + "\"");
@@ -175,9 +221,10 @@
}
catch (IOException exception) {
throw new MojoExecutionException(
- "Can't copy artifact from \"" +
artifactFrom.getAbsolutePath() + "\" " +
- "to \"" + artifactTo.getAbsolutePath() + "\"",
- exception);
+ "Can't copy artifact from \"" + artifactFrom.getAbsolutePath()
+
+ "\" to \"" + artifactTo.getAbsolutePath() + "\"",
+ exception
+ );
}
}
--
To view, visit http://gerrit.ovirt.org/18222
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id9f242083df287d01170183ad092a4b2bccb38ad
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches