Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #185 from kutzi/maven-dep-calculation

[JENKINS-9301] don't recalculate dependency graph if modules haven't changed
  • Loading branch information...
commit 05131ef1b311f625bcfa836372479b4a7f7a2a49 2 parents ee077a0 + 65678ad
@kutzi kutzi authored
View
9 maven-plugin/src/main/java/hudson/maven/MavenModule.java
@@ -191,6 +191,15 @@ public boolean isBuildable() {
}
}
}
+
+ /**
+ * Returns if the given POM likely describes the same module with the same dependencies.
+ * Implementation needs not be 100% accurate in the true case, but it MUST return false
+ * if is not the same.
+ */
+ public boolean isSameModule(PomInfo pom) {
+ return pom.isSimilar(this.moduleName, this.dependencies);
+ }
@Override
protected void doSetName(String name) {
View
12 maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java
@@ -842,6 +842,8 @@ private void parsePoms(BuildListener listener, PrintStream logger, EnvVars envVa
}
throw new AbortException();
}
+
+ boolean needsDependencyGraphRecalculation = false;
// update the module list
Map<ModuleName,MavenModule> modules = project.modules;
@@ -858,12 +860,16 @@ private void parsePoms(BuildListener listener, PrintStream logger, EnvVars envVa
if(mm!=null) {// found an existing matching module
if(debug)
logger.println("Reconfiguring "+mm);
+ if (!mm.isSameModule(pom)) {
+ needsDependencyGraphRecalculation = true;
+ }
mm.reconfigure(pom);
modules.put(pom.name,mm);
} else {// this looks like a new module
logger.println(Messages.MavenModuleSetBuild_DiscoveredModule(pom.name,pom.displayName));
mm = new MavenModule(project,pom,getNumber());
modules.put(mm.getModuleName(),mm);
+ needsDependencyGraphRecalculation = true;
}
sortedModules.add(mm);
mm.save();
@@ -877,12 +883,16 @@ private void parsePoms(BuildListener listener, PrintStream logger, EnvVars envVa
if(debug)
logger.println("Disabling "+om);
om.makeDisabled(true);
+ needsDependencyGraphRecalculation = true;
}
modules.putAll(old);
}
// we might have added new modules
- Jenkins.getInstance().rebuildDependencyGraph();
+ if (needsDependencyGraphRecalculation) {
+ logger.println("Modules changed, recalculating dependency graph");
+ Jenkins.getInstance().rebuildDependencyGraph();
+ }
// module builds must start with this build's number
for (MavenModule m : modules.values())
View
11 maven-plugin/src/main/java/hudson/maven/PomInfo.java
@@ -155,7 +155,7 @@ public PomInfo(MavenProject project, PomInfo parent, String relPath) {
this.groupId = project.getGroupId();
this.artifactId = project.getArtifactId();
}
-
+
/**
* Creates {@link ModuleDependency} that represents this {@link PomInfo}.
*/
@@ -230,6 +230,15 @@ public boolean equals( Object obj )
}
/**
+ * Returns if groupId, artifactId and dependencies are the same.
+ */
+ public boolean isSimilar(ModuleName moduleName, Set<ModuleDependency> dependencies) {
+ return StringUtils.equals(this.groupId, moduleName.groupId)
+ && StringUtils.equals(this.artifactId, moduleName.artifactId)
+ && this.dependencies.equals(dependencies);
+ }
+
+ /**
* for debug purpose
*/
public String toString() {
Please sign in to comment.
Something went wrong with that request. Please try again.