Skip to content

Commit

Permalink
Merge pull request #340 from flowlogix/local-resolver
Browse files Browse the repository at this point in the history
[SHRINKRES-351] enh: Update components resulted from project-local resolution
  • Loading branch information
petrberan authored Oct 15, 2024
2 parents d4cdfaf + 7a4a847 commit 953b648
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 112 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
# https://api.adoptium.net/v3/info/available_releases
# To list the available releases for a given "feature version" (example for 16):
# https://api.adoptium.net/v3/assets/latest/16/hotspot
java: [8, 11]
java: [8, 11, 17]

name: Build with JDK ${{ matrix.java }}

Expand Down
9 changes: 5 additions & 4 deletions maven/impl-maven-archive/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,17 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-classworlds</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>javax.enterprise</groupId>
<artifactId>cdi-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>${version.com.google.guice}</version>
</dependency>


<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,15 @@
import java.util.logging.Logger;
import java.util.regex.Pattern;

import com.google.inject.Guice;
import org.codehaus.plexus.compiler.CompilerConfiguration;
import org.codehaus.plexus.compiler.CompilerException;
import org.codehaus.plexus.compiler.CompilerMessage;
import org.codehaus.plexus.compiler.CompilerResult;
import org.codehaus.plexus.compiler.javac.JavacCompiler;
import org.eclipse.sisu.space.SpaceModule;
import org.eclipse.sisu.space.URLClassSpace;
import org.eclipse.sisu.wire.WireModule;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.resolver.api.maven.MavenResolvedArtifact;
import org.jboss.shrinkwrap.resolver.api.maven.MavenWorkingSession;
Expand All @@ -38,6 +42,7 @@
import org.jboss.shrinkwrap.resolver.impl.maven.task.AddScopedDependenciesTask;
import org.jboss.shrinkwrap.resolver.impl.maven.util.Validate;
import org.jboss.shrinkwrap.resolver.spi.maven.archive.packaging.PackagingProcessor;
import static org.eclipse.sisu.space.SpaceModule.LOCAL_INDEX;

/**
* Packaging processor which is able to compile Java sources
Expand All @@ -63,7 +68,9 @@ protected PackagingProcessor<ARCHIVETYPE> configure(MavenWorkingSession session)
if (skipCompilation) {
log.fine("Compilation was skipped due to system property org.jboss.shrinkwrap.resolver.maven.importer.skipCompilation being set to true");
} else {
compiler = new JavacCompiler();
compiler = Guice.createInjector(new WireModule(
new SpaceModule(new URLClassSpace(AbstractCompilingProcessor.class.getClassLoader()),
LOCAL_INDEX, true))).getInstance(JavacCompiler.class);
}
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void additionalCompilerArgs() {
CompilerPluginConfiguration configuration = new CompilerPluginConfiguration(session.getParsedPomFile());
CompilerConfiguration compilerConf = configuration.asCompilerConfiguration();
compilerConf.setOutputLocation("target");
String[] args = JavacCompiler.buildCompilerArguments(compilerConf, new String[0]);
String[] args = JavacCompiler.buildCompilerArguments(compilerConf, new String[0], compilerConf.getSourceVersion());

assertThat(Arrays.asList(args),
hasItems("-verbose", "-Xlint:unchecked", "-Xlint:cast", "-source", "1.7"));
Expand All @@ -59,7 +59,7 @@ void compilerEncoding() {
CompilerPluginConfiguration configuration = new CompilerPluginConfiguration(session.getParsedPomFile());
CompilerConfiguration compilerConf = configuration.asCompilerConfiguration();
compilerConf.setOutputLocation("target");
String[] args = JavacCompiler.buildCompilerArguments(compilerConf, new String[0]);
String[] args = JavacCompiler.buildCompilerArguments(compilerConf, new String[0], compilerConf.getSourceVersion());

assertThat(Arrays.asList(args),
hasItems("-verbose", "-Xlint:unchecked", "-Xlint:cast", "-source", "1.7", "-encoding", "ISO-8859-2"));
Expand All @@ -74,7 +74,7 @@ void compilerEncodingFromProperty() {
CompilerPluginConfiguration configuration = new CompilerPluginConfiguration(session.getParsedPomFile());
CompilerConfiguration compilerConf = configuration.asCompilerConfiguration();
compilerConf.setOutputLocation("target");
String[] args = JavacCompiler.buildCompilerArguments(compilerConf, new String[0]);
String[] args = JavacCompiler.buildCompilerArguments(compilerConf, new String[0], compilerConf.getSourceVersion());

assertThat(Arrays.asList(args),
hasItems("-verbose", "-Xlint:unchecked", "-Xlint:cast", "-source", "1.7", "-encoding", "ISO-8859-2"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void additionalCompilerArguments() {
CompilerPluginConfiguration configuration = new CompilerPluginConfiguration(session.getParsedPomFile());
CompilerConfiguration compilerConf = configuration.asCompilerConfiguration();
compilerConf.setOutputLocation("target");
String[] args = JavacCompiler.buildCompilerArguments(compilerConf, new String[0]);
String[] args = JavacCompiler.buildCompilerArguments(compilerConf, new String[0], compilerConf.getSourceVersion());



Expand Down
5 changes: 5 additions & 0 deletions maven/impl-maven-embedded/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
<artifactId>maven-invoker</artifactId>
<version>${version.org.apache.maven-invoker}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@ private void setOutputHandlers(String expectedRegex, CountDownLatch countDownLat
new ResolverErrorOutputHandler(logBuffer, expectedRegex, countDownLatch);
ResolverOutputHandler outputHandler = new ResolverOutputHandler(logBuffer, expectedRegex, countDownLatch);

invoker.setOutputHandler(outputHandler);
invocationRequest.setOutputHandler(outputHandler);

invoker.setErrorHandler(errorOutputHandler);
invocationRequest.setErrorHandler(errorOutputHandler);

errorOutputHandler.setQuiet(quiet);
Expand All @@ -54,7 +51,7 @@ public BuiltProject build(String expectedRegex, CountDownLatch countDownLatch) {
final String oldValue = removeSAXParserFactoryProperty();

if (mavenInstallation != null) {
invoker.setMavenHome(mavenInstallation);
invocationRequest.setMavenHome(mavenInstallation);
}

setOutputHandlers(expectedRegex, countDownLatch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,11 @@ public ConfigurationDistributionStage setLogger(InvokerLogger invokerLogger) {
@Override
public ConfigurationDistributionStage setWorkingDirectory(File workingDirectory) {
getInvocationRequest().setBaseDirectory(workingDirectory);
getInvoker().setWorkingDirectory(workingDirectory);
return this;
}

@Override
public ConfigurationDistributionStage setInputStream(InputStream inputStream) {
getInvoker().setInputStream(inputStream);
getInvocationRequest().setInputStream(inputStream);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void runTest() {

softly.assertThat(invoker.getLogger()).isEqualTo(invokerLogger);
softly.assertThat(invoker.getLocalRepositoryDirectory()).isEqualTo(localRepositoryDirectory);
softly.assertThat(invoker.getWorkingDirectory()).isEqualTo(workingDirectory);
softly.assertThat(invocationRequest.getBaseDirectory()).isEqualTo(workingDirectory);
softly.assertThat(invoker.getLogger().getThreshold()).isEqualTo(InvokerLogger.DEBUG);

boolean hasFailed = false;
Expand All @@ -122,8 +122,8 @@ void runTest() {
Assertions.fail("Maven build execution should fail as the local repository location is NOT a directory");
}

softly.assertThat(invoker.getMavenHome()).isNotNull();
softly.assertThat(invoker.getMavenHome().getName()).isEqualTo("apache-maven-3.3.9");
softly.assertThat(invocationRequest.getMavenHome()).isNotNull();
softly.assertThat(invocationRequest.getMavenHome().getName()).isEqualTo("apache-maven-3.3.9");
}

private ConfigurationStageImpl getConfigurationStageImpl(File jarSamplePom) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void testJarSampleBuildWithDebugLoggerLevelShouldDisplayCommand() {
.build();

final String logOutput = logOutputStream.toString();
Assertions.assertThat(logOutput).contains("[DEBUG] Using ${maven.home} of:");
Assertions.assertThat(logOutput).contains("[DEBUG] Using maven.home of:");
final String expectedExecPattern = System.getProperty("os.name").startsWith("Windows")
? "\\[DEBUG\\] Executing: cmd.exe /X /C .+bin\\\\mvn.+skipTests=true.+clean.+verify"
: "\\[DEBUG\\] Executing: /bin/sh -c cd .+jar-sample.+bin/mvn.+skipTests=true.+clean.+verify";
Expand Down
16 changes: 6 additions & 10 deletions maven/impl-maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,22 @@
<artifactId>plexus-classworlds</artifactId>
<version>${version.org.codehaus.plexus-classworlds}</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
<version>${version.org.codehaus.plexus-component-annotations}</version>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.plexus</artifactId>
<version>${version.org.eclipse.plexus}</version> <!-- Note: older version imported from Maven parent, but use latest -->
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-component-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-classworlds</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
<artifactId>org.eclipse.sisu.inject</artifactId>
<version>${version.org.eclipse.plexus}</version>
</dependency>
<!-- Sisu Inject/Plexus leaves to user to "bring in" Guice: runtime needed only -->
<dependency>
<groupId>com.google.inject</groupId>
Expand Down Expand Up @@ -298,7 +294,7 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<additionalClasspathElements>
<additionalClasspathElements combine.children="append">
<additionalClasspathElement>${appended.jar.for.test}</additionalClasspathElement>
</additionalClasspathElements>
</configuration>
Expand Down

This file was deleted.

17 changes: 11 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.jboss</groupId>
<artifactId>jboss-parent</artifactId>
<version>39</version>
<version>46</version>
</parent>

<!-- Model Information -->
Expand All @@ -28,21 +28,21 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.argument.target>1.8</maven.compiler.argument.target>
<maven.compiler.argument.source>1.8</maven.compiler.argument.source>
<version.checkstyle>9.3</version.checkstyle>

<!-- Versioning -->
<version.com.google.guice>7.0.0</version.com.google.guice>
<version.com.google.guice>6.0.0</version.com.google.guice>
<version.commons-codec>1.17.1</version.commons-codec>
<version.commons-compress>1.27.1</version.commons-compress>
<version.commons-io>2.17.0</version.commons-io>
<version.eu.maveniverse.mima>2.4.20</version.eu.maveniverse.mima>
<version.org.apache.maven>3.9.9</version.org.apache.maven>
<version.org.apache.maven-plugin-annotations>3.15.0</version.org.apache.maven-plugin-annotations>
<version.org.apache.maven-invoker>3.0.1</version.org.apache.maven-invoker>
<version.org.apache.maven-invoker>3.3.0</version.org.apache.maven-invoker>
<version.org.codehaus.plexus-classworlds>2.8.0</version.org.codehaus.plexus-classworlds>
<version.org.codehaus.plexus-compiler-javac>2.7</version.org.codehaus.plexus-compiler-javac>
<version.org.codehaus.plexus-component-annotations>2.2.0</version.org.codehaus.plexus-component-annotations>
<version.org.codehaus.plexus-compiler-javac>2.15.0</version.org.codehaus.plexus-compiler-javac>
<version.org.codehaus.plexus-sec-dispatcher>2.0</version.org.codehaus.plexus-sec-dispatcher>
<version.org.eclipse.plexus>0.3.5</version.org.eclipse.plexus>
<version.org.eclipse.plexus>0.9.0.M3</version.org.eclipse.plexus>
<version.org.gradle.gradle-tooling-api>8.10.2</version.org.gradle.gradle-tooling-api>
<version.org.jboss.shrinkwrap>1.2.6</version.org.jboss.shrinkwrap>

Expand Down Expand Up @@ -131,6 +131,11 @@
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>${version.com.google.guice}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
Expand Down

0 comments on commit 953b648

Please sign in to comment.