mirror of
https://github.com/jenkinsci/jenkins.git
synced 2026-11-16 05:22:22 +00:00
[FIXED JENKINS-17775] Find (model) parent POMs properly during fingerprint recording at end of build.
This commit is contained in:
1 parent
f6a8c31f6c
commit
0c4fe2ddba
4 files changed
+67
-58
No files matched your search
@@ -65,6 +65,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InterruptedIOException;
|
||||
import java.io.PrintStream;
|
||||
import java.io.Serializable;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -582,7 +583,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
LOGGER.fine(getFullDisplayName()+" is building with mavenVersion " + mavenVersion + " from file " + mavenInformation.getVersionResourcePath());
|
||||
|
||||
if(!project.isAggregatorStyleBuild()) {
|
||||
parsePoms(listener, logger, envVars, mvn, mavenVersion);
|
||||
parsePoms(listener, logger, envVars, mvn, mavenVersion, mavenBuildInformation);
|
||||
// start module builds
|
||||
logger.println("Triggering "+project.getRootModule().getModuleName());
|
||||
project.getRootModule().scheduleBuild(new UpstreamCause((Run<?,?>)MavenModuleSetBuild.this));
|
||||
@@ -619,7 +620,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
return r;
|
||||
}
|
||||
|
||||
parsePoms(listener, logger, envVars, mvn, mavenVersion); // #5428 : do pre-build *before* parsing pom
|
||||
parsePoms(listener, logger, envVars, mvn, mavenVersion, mavenBuildInformation); // #5428 : do pre-build *before* parsing pom
|
||||
SplittableBuildListener slistener = new SplittableBuildListener(listener);
|
||||
proxies = new HashMap<ModuleName, ProxyImpl2>();
|
||||
List<ModuleName> changedModules = new ArrayList<ModuleName>();
|
||||
@@ -856,12 +857,14 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
return unbuiltModules;
|
||||
}
|
||||
|
||||
private void parsePoms(BuildListener listener, PrintStream logger, EnvVars envVars, MavenInstallation mvn, String mavenVersion) throws IOException, InterruptedException {
|
||||
private void parsePoms(BuildListener listener, PrintStream logger, EnvVars envVars, MavenInstallation mvn, String mavenVersion, MavenBuildInformation mavenBuildInformation) throws IOException, InterruptedException {
|
||||
logger.println("Parsing POMs");
|
||||
|
||||
List<PomInfo> poms;
|
||||
try {
|
||||
poms = getModuleRoot().act(new PomParser(listener, mvn, mavenVersion, envVars, MavenModuleSetBuild.this));
|
||||
PomParser.Result result = getModuleRoot().act(new PomParser(listener, mvn, mavenVersion, envVars, MavenModuleSetBuild.this));
|
||||
poms = result.infos;
|
||||
mavenBuildInformation.modelParents.putAll(result.modelParents);
|
||||
} catch (IOException e) {
|
||||
if (project.isIncrementalBuild()) {
|
||||
// If POM parsing failed we should do a full build next time.
|
||||
@@ -997,7 +1000,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
* Executed on the slave to parse POM and extract information into {@link PomInfo},
|
||||
* which will be then brought back to the master.
|
||||
*/
|
||||
private static final class PomParser implements FileCallable<List<PomInfo>> {
|
||||
private static final class PomParser implements FileCallable<PomParser.Result> {
|
||||
private final BuildListener listener;
|
||||
private final String rootPOM;
|
||||
/**
|
||||
@@ -1028,7 +1031,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
|
||||
String rootPOMRelPrefix;
|
||||
|
||||
public PomParser(BuildListener listener, MavenInstallation mavenHome, String mavenVersion, EnvVars envVars, MavenModuleSetBuild build) {
|
||||
PomParser(BuildListener listener, MavenInstallation mavenHome, String mavenVersion, EnvVars envVars, MavenModuleSetBuild build) {
|
||||
// project cannot be shipped to the remote JVM, so all the relevant properties need to be captured now.
|
||||
MavenModuleSet project = build.getProject();
|
||||
this.listener = listener;
|
||||
@@ -1082,7 +1085,16 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
return StringUtils.contains(goals, "-U") || StringUtils.contains(goals, "--update-snapshots");
|
||||
}
|
||||
|
||||
public List<PomInfo> invoke(File ws, VirtualChannel channel) throws IOException {
|
||||
public static final class Result implements Serializable {
|
||||
public final List<PomInfo> infos;
|
||||
public final Map<String,String> modelParents;
|
||||
public Result(List<PomInfo> infos, Map<String,String> modelParents) {
|
||||
this.infos = infos;
|
||||
this.modelParents = modelParents;
|
||||
}
|
||||
}
|
||||
|
||||
public Result invoke(File ws, VirtualChannel channel) throws IOException {
|
||||
File pom;
|
||||
|
||||
PrintStream logger = listener.getLogger();
|
||||
@@ -1194,10 +1206,23 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
}
|
||||
}
|
||||
Map<String,MavenProject> canonicalPaths = new HashMap<String, MavenProject>( mps.size() );
|
||||
Map<String,String> modelParents = new HashMap<String,String>();
|
||||
for(MavenProject mp : mps) {
|
||||
// Projects are indexed by POM path and not module path because
|
||||
// Maven allows to have several POMs with different names in the same directory
|
||||
canonicalPaths.put( mp.getFile().getCanonicalPath(), mp );
|
||||
while (true) {
|
||||
String k = mp.getId();
|
||||
if (modelParents.containsKey(k)) {
|
||||
break;
|
||||
}
|
||||
MavenProject mpp = mp.getParent();
|
||||
if (mpp == null) {
|
||||
break;
|
||||
}
|
||||
modelParents.put(k, mpp.getId());
|
||||
mp = mpp;
|
||||
}
|
||||
}
|
||||
//MavenUtil.resolveModules(embedder,mp,getRootPath(rootPOMRelPrefix),relPath,listener,nonRecursive);
|
||||
|
||||
@@ -1225,7 +1250,7 @@ public class MavenModuleSetBuild extends AbstractMavenBuild<MavenModuleSet,Maven
|
||||
for (PomInfo pi : infos)
|
||||
pi.cutCycle();
|
||||
|
||||
return new ArrayList<PomInfo>(infos);
|
||||
return new Result(new ArrayList<PomInfo>(infos), modelParents);
|
||||
} catch (MavenEmbedderException e) {
|
||||
throw new MavenExecutionException(e);
|
||||
} catch (ProjectBuildingException e) {
|
||||
|
||||
Reference in new issue
Block a user