|
9 | 9 | import java.io.IOException;
|
10 | 10 | import java.nio.file.Files;
|
11 | 11 | import java.nio.file.Path;
|
12 |
| -import java.util.*; |
| 12 | +import java.util.ArrayList; |
| 13 | +import java.util.Collections; |
| 14 | +import java.util.List; |
| 15 | +import java.util.Map; |
| 16 | +import java.util.Optional; |
| 17 | +import java.util.Set; |
13 | 18 |
|
14 | 19 | import javax.enterprise.inject.Instance;
|
15 | 20 | import javax.inject.Inject;
|
16 | 21 |
|
| 22 | +import org.apache.commons.cli.ParseException; |
| 23 | +import org.apache.maven.cli.CLIManager; |
17 | 24 | import org.apache.maven.model.Model;
|
18 | 25 | import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
|
19 | 26 | import org.eclipse.jgit.api.Git;
|
@@ -110,8 +117,30 @@ private void doBuildAnalysis(String scmUrl, String scmTag, String context, Build
|
110 | 117 | }
|
111 | 118 | BuildInfo info = new BuildInfo();
|
112 | 119 | info.commitTime = time;
|
113 |
| - Path pomFile = path.resolve("pom.xml"); |
| 120 | + Path pomFile = null; |
| 121 | + if (buildRecipeInfo != null && buildRecipeInfo.getAdditionalArgs() != null) { |
| 122 | + try { |
| 123 | + CLIManager cliManager = new CLIManager(); |
| 124 | + org.apache.commons.cli.CommandLine commandLine = cliManager |
| 125 | + .parse(buildRecipeInfo.getAdditionalArgs().toArray(new String[0])); |
| 126 | + if (commandLine.hasOption(CLIManager.ALTERNATE_POM_FILE)) { |
| 127 | + String alternatePomFile = commandLine.getOptionValue(CLIManager.ALTERNATE_POM_FILE); |
| 128 | + if (alternatePomFile != null) { |
| 129 | + pomFile = path.resolve(alternatePomFile); |
| 130 | + if (Files.isDirectory(pomFile)) { |
| 131 | + pomFile = pomFile.resolve("pom.xml"); |
| 132 | + } |
| 133 | + } |
| 134 | + } |
| 135 | + } catch (ParseException e) { |
| 136 | + Log.errorf(e, "Failed to parse command line %s", buildRecipeInfo.getAdditionalArgs()); |
| 137 | + } |
| 138 | + } |
| 139 | + if (pomFile == null) { |
| 140 | + pomFile = path.resolve("pom.xml"); |
| 141 | + } |
114 | 142 | if (Files.isRegularFile(pomFile)) {
|
| 143 | + Log.infof("Found Maven pom file at %s", pomFile); |
115 | 144 | try (BufferedReader pomReader = Files.newBufferedReader(pomFile)) {
|
116 | 145 | MavenXpp3Reader reader = new MavenXpp3Reader();
|
117 | 146 | Model model = reader.read(pomReader);
|
|
0 commit comments