Martin Peřina has uploaded a new change for review.

Change subject: build: Add artifactProvided to module definition
......................................................................

build: Add artifactProvided to module definition

Adds artifactProvided (by default false) to module definition using
which we can suppress adding artifact jars to module and create module
which just exports existing modules (this will be used in following
patch to export slf4j provided by JBoss).

Change-Id: I71b68b1d1d4222ffba91be957cb764a54f658519
Related-To: https://bugzilla.redhat.com/1109871
Signed-off-by: Martin Perina <mper...@redhat.com>
---
M 
build-tools-root/jboss-modules-maven-plugin/src/main/java/org/ovirt/engine/build/Module.java
M 
build-tools-root/jboss-modules-maven-plugin/src/main/java/org/ovirt/engine/build/ModulesMojo.java
2 files changed, 70 insertions(+), 61 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/48/32848/1

diff --git 
a/build-tools-root/jboss-modules-maven-plugin/src/main/java/org/ovirt/engine/build/Module.java
 
b/build-tools-root/jboss-modules-maven-plugin/src/main/java/org/ovirt/engine/build/Module.java
index 5fbddd0..3580ab7 100644
--- 
a/build-tools-root/jboss-modules-maven-plugin/src/main/java/org/ovirt/engine/build/Module.java
+++ 
b/build-tools-root/jboss-modules-maven-plugin/src/main/java/org/ovirt/engine/build/Module.java
@@ -23,9 +23,10 @@
     private String groupId;
     private String moduleName;
     private String moduleSlot;
+    private boolean artifactProvided;
 
     public Module() {
-        // Nothing.
+        artifactProvided = false;
     }
 
     public String getArtifactId() {
@@ -66,6 +67,14 @@
         this.moduleSlot = moduleSlot;
     }
 
+    public boolean isArtifactProvided() {
+        return artifactProvided;
+    }
+
+    public void setArtifactProvided(boolean artifactProvided) {
+        this.artifactProvided = artifactProvided;
+    }
+
     public String getResourcePath() {
         return artifactId + ".jar";
     }
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 f231089..1fda945 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
@@ -181,71 +181,71 @@
             }
         }
 
-        // Find the dependency with the same group and artifact id that the 
module:
-        Artifact matchingArtifact = null;
-        if (module.matches(project.getArtifact())) {
-            matchingArtifact = project.getArtifact();
-        }
-        else {
-            for (Artifact currentArtifact: project.getDependencyArtifacts()) {
-                if (module.matches(currentArtifact)) {
-                    matchingArtifact = currentArtifact;
-               }
+        if (!module.isArtifactProvided()) {
+            // Find the dependency with the same group and artifact id that 
the module:
+            Artifact matchingArtifact = null;
+            if (module.matches(project.getArtifact())) {
+                matchingArtifact = project.getArtifact();
+            } else {
+                for (Artifact currentArtifact : 
project.getDependencyArtifacts()) {
+                    if (module.matches(currentArtifact)) {
+                        matchingArtifact = currentArtifact;
+                    }
+                }
             }
-        }
-        if (matchingArtifact == null) {
-            throw new MojoExecutionException(
-                    "Can't find dependency matching artifact id \"" + 
module.getArtifactId() + "\" " +
-                    "and group id \"" + module.getGroupId() + "\"");
-        }
-
-        // Copy the artifact to the temporary directory (this is needed 
because the index generator has a bug and will
-        // remove the file if it isn't in the same file system that the 
temporary file it uses internally):
-        File artifactFrom = matchingArtifact.getFile();
-        if (artifactFrom == null) {
-            throw new MojoExecutionException(
-                "Can't find file for artifact id \"" + module.getArtifactId() 
+ "\" " + "and group id \"" +
-                module.getGroupId() + "\""
-            );
-        }
-        File artifactTmp;
-        try {
-            artifactTmp = File.createTempFile("index", null);
-            FileUtils.copyFile(artifactFrom, artifactTmp);
-        }
-        catch (IOException exception) {
-            throw new MojoExecutionException(
-                "Can't create temporary file for \"" + 
artifactFrom.getAbsolutePath() + "\".",
-                exception
-            );
-        }
-
-        // Add the annotations index to the temporary file:
-        if (generateIndex) {
-            getLog().info("Creating annotations index for \"" + 
artifactFrom.getAbsolutePath() + "\"");
-            try {
-                JarIndexer.createJarIndex(artifactTmp, new Indexer(), true, 
false, false);
-            }
-            catch (IOException exception) {
+            if (matchingArtifact == null) {
                 throw new MojoExecutionException(
-                    "Can't add annotations index to \"" + 
artifactTmp.getAbsolutePath() + "\".",
-                     exception
+                        "Can't find dependency matching artifact id \"" + 
module.getArtifactId() + "\" " +
+                                "and group id \"" + module.getGroupId() + 
"\"");
+            }
+
+            // Copy the artifact to the temporary directory (this is needed 
because the index generator has a bug and will
+            // remove the file if it isn't in the same file system that the 
temporary file it uses internally):
+            File artifactFrom = matchingArtifact.getFile();
+            if (artifactFrom == null) {
+                throw new MojoExecutionException(
+                        "Can't find file for artifact id \"" + 
module.getArtifactId() + "\" " + "and group id \"" +
+                                module.getGroupId() + "\""
                 );
             }
-        }
 
-        // Move the temporary artifact file (maybe modified to include the 
index) to the slot directory:
-        File artifactTo = new File(slotDir, module.getResourcePath());
-        getLog().info("Copying artifact to \"" + artifactTo.getAbsolutePath() 
+ "\"");
-        try {
-            FileUtils.rename(artifactTmp, artifactTo);
-        }
-        catch (IOException exception) {
-            throw new MojoExecutionException(
-                "Can't move temporary file \"" + artifactTmp.getAbsolutePath() 
+ "\" to slot directory \"" +
-                slotDir.getAbsolutePath() + "\".",
-                exception
-            );
+            File artifactTmp;
+            try {
+                artifactTmp = File.createTempFile("index", null);
+                FileUtils.copyFile(artifactFrom, artifactTmp);
+            } catch (IOException exception) {
+                throw new MojoExecutionException(
+                        "Can't create temporary file for \"" + 
artifactFrom.getAbsolutePath() + "\".",
+                        exception
+                );
+            }
+
+            // Add the annotations index to the temporary file:
+            if (generateIndex) {
+                getLog().info("Creating annotations index for \"" + 
artifactFrom.getAbsolutePath() + "\"");
+                try {
+                    JarIndexer.createJarIndex(artifactTmp, new Indexer(), 
true, false, false);
+                }
+                catch (IOException exception) {
+                    throw new MojoExecutionException(
+                            "Can't add annotations index to \"" + 
artifactTmp.getAbsolutePath() + "\".",
+                            exception
+                    );
+                }
+            }
+
+            // Move the temporary artifact file (maybe modified to include the 
index) to the slot directory:
+            File artifactTo = new File(slotDir, module.getResourcePath());
+            getLog().info("Copying artifact to \"" + 
artifactTo.getAbsolutePath() + "\"");
+            try {
+                FileUtils.rename(artifactTmp, artifactTo);
+            } catch (IOException exception) {
+                throw new MojoExecutionException(
+                        "Can't move temporary file \"" + 
artifactTmp.getAbsolutePath() + "\" to slot directory \"" +
+                                slotDir.getAbsolutePath() + "\".",
+                        exception
+                );
+            }
         }
     }
 


-- 
To view, visit http://gerrit.ovirt.org/32848
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I71b68b1d1d4222ffba91be957cb764a54f658519
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Martin Peřina <mper...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to