diff --git a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/build/InvocationBuilder.java b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/build/InvocationBuilder.java index a172a741e..e10ac46e4 100644 --- a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/build/InvocationBuilder.java +++ b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/analyser/build/InvocationBuilder.java @@ -132,6 +132,7 @@ public BuildInfo build(CacheBuildInfoLocator buildInfoLocator) { info.setAdditionalDownloads(buildRecipeInfo.getAdditionalDownloads()); info.setAdditionalMemory(buildRecipeInfo.getAdditionalMemory()); info.setAllowedDifferences(buildRecipeInfo.getAllowedDifferences()); + info.setDisabledPlugins(buildRecipeInfo.getDisabledPlugins()); } //now we need to figure out what possible build recipes we can try //we work through from lowest Java version to highest diff --git a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/gradle/GradlePrepareCommand.java b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/gradle/GradlePrepareCommand.java index e1b8b68fc..9e53c83f0 100644 --- a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/gradle/GradlePrepareCommand.java +++ b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/gradle/GradlePrepareCommand.java @@ -1,12 +1,19 @@ package com.redhat.hacbs.container.build.preprocessor.gradle; +import static com.redhat.hacbs.container.analyser.build.BuildInfo.GRADLE; + import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; +import org.eclipse.microprofile.rest.client.RestClientBuilder; + +import com.redhat.hacbs.container.analyser.build.CacheBuildInfoLocator; import com.redhat.hacbs.container.build.preprocessor.AbstractPreprocessor; import io.quarkus.logging.Log; @@ -46,13 +53,13 @@ public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IO } }); - } catch (IOException e) { + } catch (IOException | URISyntaxException e) { throw new RuntimeException(e); } } - private void setupInitScripts() throws IOException { + private void setupInitScripts() throws IOException, URISyntaxException { var initDir = buildRoot.resolve(".hacbs-init"); Files.createDirectories(initDir); for (var initScript : INIT_SCRIPTS) { @@ -61,6 +68,10 @@ private void setupInitScripts() throws IOException { Files.copy(in, init); if ("disable-plugins.gradle".equals(init.getFileName().toString())) { + var buildInfoLocator = RestClientBuilder.newBuilder().baseUri(new URI(repositoryUrl)) + .build(CacheBuildInfoLocator.class); + var defaultPlugins = buildInfoLocator.lookupPluginInfo(GRADLE); + disabledPlugins.addAll(defaultPlugins); Files.writeString(init, Files.readString(init).replace("@DISABLED_PLUGINS@", String.join(",", disabledPlugins))); } diff --git a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/maven/MavenPrepareCommand.java b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/maven/MavenPrepareCommand.java index a2d514848..dfbd8fa76 100644 --- a/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/maven/MavenPrepareCommand.java +++ b/java-components/build-request-processor/src/main/java/com/redhat/hacbs/container/build/preprocessor/maven/MavenPrepareCommand.java @@ -1,9 +1,12 @@ package com.redhat.hacbs.container.build.preprocessor.maven; import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; +import static com.redhat.hacbs.container.analyser.build.BuildInfo.MAVEN; import java.io.BufferedReader; import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; @@ -18,9 +21,11 @@ import org.apache.maven.model.io.xpp3.MavenXpp3Reader; import org.apache.maven.model.io.xpp3.MavenXpp3Writer; import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.eclipse.microprofile.rest.client.RestClientBuilder; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLMapper; +import com.redhat.hacbs.container.analyser.build.CacheBuildInfoLocator; import com.redhat.hacbs.container.build.preprocessor.AbstractPreprocessor; import io.quarkus.logging.Log; @@ -86,9 +91,14 @@ private void handleBuild(Path file, boolean topLevel) { } } - private boolean handlePlugins(List plugins, boolean pluginManagement, boolean topLevel) throws IOException { + private boolean handlePlugins(List plugins, boolean pluginManagement, boolean topLevel) + throws IOException, URISyntaxException { boolean modified = false; List toRemove = new ArrayList<>(); + var buildInfoLocator = RestClientBuilder.newBuilder().baseUri(new URI(repositoryUrl)) + .build(CacheBuildInfoLocator.class); + var defaultPlugins = buildInfoLocator.lookupPluginInfo(MAVEN); + disabledPlugins.addAll(defaultPlugins); for (String s : disabledPlugins) { String[] ga = s.split(":");