diff --git a/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java b/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java index d5ff1f412..a226f760a 100644 --- a/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java +++ b/plugins-compat-tester/src/main/java/org/jenkins/tools/test/PluginCompatTester.java @@ -35,6 +35,7 @@ import hudson.model.UpdateSite.Plugin; import hudson.util.VersionNumber; import io.jenkins.lib.versionnumber.JavaSpecificationVersion; + import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -74,6 +75,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; + import net.sf.json.JSONArray; import net.sf.json.JSONObject; import org.apache.commons.io.IOUtils; @@ -379,11 +381,11 @@ && new VersionNumber(coreCoordinates.version).compareTo(new VersionNumber("1.485 } if (failed && config.isFailOnError()) { - throw new AbortException("Execution was aborted due to the failure in a plugin test (-failOnError is set)"); + throw new AbortException("Execution was aborted due to the failure in a plugin test (-failOnError is set)"); } return report; - } + } protected void generateHtmlReportFile() throws IOException { if (!config.reportFile.exists() || !config.reportFile.isFile()) { @@ -432,7 +434,7 @@ private TestExecutionResult testPluginAgainst(MavenCoordinates coreCoordinates, File pluginCheckoutDir = new File(config.workDirectory.getAbsolutePath() + File.separator + plugin.name + File.separator); - try { + try { // Run any precheckout hooks Map beforeCheckout = new HashMap<>(); beforeCheckout.put("pluginName", plugin.name); @@ -652,11 +654,11 @@ private UpdateSite.Data extractUpdateCenterData(Map groupIDs){ } private UpdateSite.Data scanBom(HashMap pluginGroupIds, String pluginRegExp) throws IOException, PomExecutionException, XmlPullParserException { - + JSONObject top = new JSONObject(); top.put("id", DEFAULT_SOURCE_ID); JSONObject plugins = new JSONObject(); - + for (File entry : getBomEntries()) { String name = entry.getName(); Matcher m = Pattern.compile(pluginRegExp).matcher(name); @@ -762,9 +764,9 @@ private String solveVersionFromModel(Model model) { Parent parent = model.getParent(); return version != null ? version : parent != null ? parent.getVersion() : StringUtils.EMPTY; } - + /** - * Given a value and a model, it checks if it is an interpolated value. In negative case it returns the same + * Given a value and a model, it checks if it is an interpolated value. In negative case it returns the same * value. In affirmative case, it retrieves its value from the properties of the Maven model. * @param model * @param version @@ -774,11 +776,11 @@ private String getProperty(Model model, String value) { if (!value.contains("$")) { return value; } - + String key = value.replaceAll("\\$", "") .replaceAll("\\{", "") .replaceAll("\\}", ""); - + return getProperty(model, model.getProperties().getProperty(key)); } @@ -997,6 +999,12 @@ private void addSplitPluginDependencies(String thisPlugin, MavenRunner.Config mc toAddTest = difference(pluginDeps, toAddTest); toAddTest = difference(toAdd, toAddTest); + if(toReplaceTest.containsKey("configuration-as-code")){ + VersionNumber versionNumber = toReplaceTest.get("configuration-as-code"); + pluginGroupIds.put("test-harness", "io.jenkins.configuration-as-code"); + toReplaceTest.put("test-harness", versionNumber); + } + if (!toAdd.isEmpty() || !toReplace.isEmpty() || !toAddTest.isEmpty() || !toReplaceTest.isEmpty()) { System.out.println("Adding/replacing plugin dependencies for compatibility: " + toAdd + " " + toReplace + "\nFor test: " + toAddTest + " " + toReplaceTest); pom.addDependencies(toAdd, toReplace, toAddTest, toReplaceTest, coreDep, pluginGroupIds, convertFromTestDep);