mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 21:42:27 +00:00
Merge pull request #185 from kutzi/maven-dep-calculation
[JENKINS-9301] don't recalculate dependency graph if modules haven't changed
This commit is contained in:
commit
05131ef1b3
3 files changed
+30
-2
No files matched your search
@@ -191,6 +191,15 @@ public final class MavenModule extends AbstractMavenProject<MavenModule,MavenBui
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
|
||||
@@ -842,6 +842,8 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
}
|
||||
throw new AbortException();
|
||||
}
|
||||
|
||||
boolean needsDependencyGraphRecalculation = false;
|
||||
|
||||
// update the module list
|
||||
Map<ModuleName,MavenModule> modules = project.modules;
|
||||
@@ -858,12 +860,16 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
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 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
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())
|
||||
|
||||
@@ -155,7 +155,7 @@ final class PomInfo implements Serializable {
|
||||
this.groupId = project.getGroupId();
|
||||
this.artifactId = project.getArtifactId();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates {@link ModuleDependency} that represents this {@link PomInfo}.
|
||||
*/
|
||||
@@ -229,6 +229,15 @@ final class PomInfo implements Serializable {
|
||||
&& StringUtils.equals( pomInfo.artifactId, this.artifactId );
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user