Skip to content

Commit

Permalink
Merge pull request #349 from mikecirioli/jdk11_dependency_resolver
Browse files Browse the repository at this point in the history
Fix dependency resolution when using java 11
  • Loading branch information
imonteroperez committed Mar 3, 2022
2 parents 1c5124e + 38875a8 commit bbc4f42
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
import org.jenkins.tools.test.model.hook.PluginCompatTesterHooks;
import org.jenkins.tools.test.util.ExecutedTestNamesSolver;
import org.springframework.core.io.ClassPathResource;
import org.jenkins.tools.test.exception.PomTransformationException;

/**
* Frontend for plugin compatibility tests
Expand Down Expand Up @@ -449,8 +450,7 @@ private static String createBuildLogFilePathFor(String pluginName, String plugin
}

private TestExecutionResult testPluginAgainst(MavenCoordinates coreCoordinates, Plugin plugin, MavenRunner.Config mconfig, PomData pomData, Map<String, Plugin> otherPlugins, Map<String, String> pluginGroupIds, PluginCompatTesterHooks pcth, List<PCTPlugin> overridenPlugins)
throws PluginSourcesUnavailableException, PomExecutionException, IOException
{
throws PluginSourcesUnavailableException, PomExecutionException, IOException, PomTransformationException {
System.out.println(String.format("%n%n%n%n%n"));
System.out.println("#############################################");
System.out.println("#############################################");
Expand Down Expand Up @@ -562,7 +562,10 @@ private TestExecutionResult testPluginAgainst(MavenCoordinates coreCoordinates,
MavenPom pom = new MavenPom(pluginCheckoutDir);
try {
addSplitPluginDependencies(plugin.name, mconfig, pluginCheckoutDir, pom, otherPlugins, pluginGroupIds, coreCoordinates.version, overridenPlugins, parentFolder);
} catch (Exception x) {
} catch (PomTransformationException x) {
throw x;
}
catch (Exception x) {
x.printStackTrace();
pomData.getWarningMessages().add(Functions.printThrowable(x));
// but continue
Expand Down Expand Up @@ -955,7 +958,7 @@ public static String getMavenModule(String plugin, File pluginPath, MavenRunner
return null;
}

private void addSplitPluginDependencies(String thisPlugin, MavenRunner.Config mconfig, File pluginCheckoutDir, MavenPom pom, Map<String, Plugin> otherPlugins, Map<String, String> pluginGroupIds, String coreVersion, List<PCTPlugin> overridenPlugins, String parentFolder) throws PomExecutionException, IOException {
private void addSplitPluginDependencies(String thisPlugin, MavenRunner.Config mconfig, File pluginCheckoutDir, MavenPom pom, Map<String, Plugin> otherPlugins, Map<String, String> pluginGroupIds, String coreVersion, List<PCTPlugin> overridenPlugins, String parentFolder) throws Exception {
File tmp = File.createTempFile("dependencies", ".log");
VersionNumber coreDep = null;
Map<String,VersionNumber> pluginDeps = new HashMap<>();
Expand All @@ -972,8 +975,8 @@ private void addSplitPluginDependencies(String thisPlugin, MavenRunner.Config mc
}
try (BufferedReader br =
Files.newBufferedReader(tmp.toPath(), Charset.defaultCharset())) {
Pattern p = Pattern.compile("\\[INFO\\]([^:]+):([^:]+):([a-z-]+):(([^:]+):)?([^:]+):(provided|compile|runtime|system)(\\(optional\\))?");
Pattern p2 = Pattern.compile("\\[INFO\\]([^:]+):([^:]+):([a-z-]+):(([^:]+):)?([^:]+):(test)");
Pattern p = Pattern.compile("\\[INFO\\]([^:]+):([^:]+):([a-z-]+):(([^:]+):)?([^:]+):(provided|compile|runtime|system)(\\(optional\\))?.*");
Pattern p2 = Pattern.compile("\\[INFO\\]([^:]+):([^:]+):([a-z-]+):(([^:]+):)?([^:]+):(test).*");
String line;
while ((line = br.readLine()) != null) {
line = line.replace(" ", "");
Expand Down Expand Up @@ -1097,6 +1100,10 @@ private void addSplitPluginDependencies(String thisPlugin, MavenRunner.Config mc
// Remove the self-dependency if any
pom.removeDependency(pluginGroupIds.get(thisPlugin), thisPlugin);
}
else {
// bad, we should always find a core dependency!
throw new PomTransformationException("No jenkins core dependency found, aborting!", new Throwable());
}
}
private void checkDefinedDeps(Map<String,VersionNumber> pluginList, Map<String,VersionNumber> adding, Map<String,VersionNumber> replacing, Map<String,Plugin> otherPlugins) {
checkDefinedDeps(pluginList, adding, replacing, otherPlugins, new ArrayList<>(), null);
Expand Down

0 comments on commit bbc4f42

Please sign in to comment.