Skip to content

Commit

Permalink
Lookup default disabled plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
dwalluck committed Nov 20, 2023
1 parent 59b190f commit 5eb1a04
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -86,9 +91,14 @@ private void handleBuild(Path file, boolean topLevel) {
}
}

private boolean handlePlugins(List<Plugin> plugins, boolean pluginManagement, boolean topLevel) throws IOException {
private boolean handlePlugins(List<Plugin> plugins, boolean pluginManagement, boolean topLevel)
throws IOException, URISyntaxException {
boolean modified = false;
List<PluginInfo> 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(":");
Expand Down

0 comments on commit 5eb1a04

Please sign in to comment.