diff --git a/CHANGELOG.md b/CHANGELOG.md index 06ebd92..04391a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,20 @@ ## 1.7.0 (unreleased) +### New features +- [[#5](https://github.com/AlexisJehan/MvnCheck/issues/5)] Generate an executable JAR as an extra release file (thanks + to [TobseF](https://github.com/TobseF)) + ### Bug fixes -- [[#3](https://github.com/AlexisJehan/MvnCheck/issues/3)] Fix parsing errors related to the BOM character of the UTF-8 with BOM encoding (thanks to [TobseF](https://github.com/TobseF)) +- [[#3](https://github.com/AlexisJehan/MvnCheck/issues/3)] Fix parsing errors related to the BOM character of the UTF-8 + with BOM encoding (thanks to [TobseF](https://github.com/TobseF)) + +### Improvements +- Improve the _Maven Artifact Resolver_ usage by migrating from `Eclipse Sisu` to `Supplier` ### Notes +- Add the `maven-resolver-supplier` dependency - Update the `maven-core` dependency to `3.9.9` -- Update `maven-resolver-connector-basic` and `maven-resolver-transport-http` dependencies to `1.9.22` - Update the `gradle-tooling-api` dependency to `8.10` - Update the `github-api` dependency to `1.324` - Update the `commons-cli` dependency to `1.9.0` @@ -18,6 +26,7 @@ - Update `maven-surefire-plugin` and `maven-failsafe-plugin` plugins to `3.5.0` - Update the `maven-javadoc-plugin` plugin to `3.10.0` - Update the `maven-gpg-plugin` plugin to `3.2.5` +- Remove `maven-resolver-connector-basic` and `maven-resolver-transport-http` dependencies ## [1.6.2](https://github.com/AlexisJehan/MvnCheck/releases/tag/v1.6.2) (2024-07-16) @@ -207,7 +216,7 @@ ### Improvements - Improve resolving the _Maven_ version -- Improve _Maven_ dependency injection by migrating from `ServiceLocator` to `Eclipse Sisu` +- Improve the _Maven Artifact Resolver_ usage by migrating from `ServiceLocator` to `Eclipse Sisu` - Improve exceptions output - Improve some log levels diff --git a/pom.xml b/pom.xml index 99fa844..1d9f544 100644 --- a/pom.xml +++ b/pom.xml @@ -76,15 +76,8 @@ org.apache.maven.resolver - maven-resolver-connector-basic + maven-resolver-supplier 1.9.22 - runtime - - - org.apache.maven.resolver - maven-resolver-transport-http - 1.9.22 - runtime org.gradle @@ -419,19 +412,41 @@ 3.7.1 - assembly-single + assembly-single-bin + package + + single + + + + src/main/assembly/bin.xml + + ${maven.build.timestamp} + + + + assembly-single-bin-jar package single + + + + true + com.github.alexisjehan.mvncheck.Application + + + true + + + + src/main/assembly/bin-jar.xml + + ${maven.build.timestamp} + - - - src/main/assembly/bin.xml - - ${maven.build.timestamp} - org.apache.maven.plugins diff --git a/src/main/assembly/bin-jar.xml b/src/main/assembly/bin-jar.xml new file mode 100644 index 0000000..60bb397 --- /dev/null +++ b/src/main/assembly/bin-jar.xml @@ -0,0 +1,29 @@ + + + bin + + jar + + false + + + / + true + true + provided + + + / + true + true + runtime + + + + + + LICENSE.txt + + + + \ No newline at end of file diff --git a/src/main/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/GradleBuildResolver.java b/src/main/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/GradleBuildResolver.java index 8068904..5e95f50 100644 --- a/src/main/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/GradleBuildResolver.java +++ b/src/main/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/GradleBuildResolver.java @@ -47,10 +47,13 @@ import java.io.IOException; import java.io.OutputStream; import java.lang.invoke.MethodHandles; +import java.nio.file.Files; import java.nio.file.Path; +import java.nio.file.StandardCopyOption; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Objects; import java.util.Set; import java.util.stream.Collectors; @@ -61,11 +64,23 @@ */ public final class GradleBuildResolver implements BuildResolver { + /** + *

Prefix of the initialisation file name.

+ * @since 1.7.0 + */ + private static final String INIT_FILE_NAME_PREFIX = "init"; + + /** + *

Suffix of the initialisation file name.

+ * @since 1.7.0 + */ + private static final String INIT_FILE_NAME_SUFFIX = ".gradle"; + /** *

Initialisation file name.

* @since 1.0.0 */ - private static final String INIT_FILE_NAME = "init.gradle"; + private static final String INIT_FILE_NAME = INIT_FILE_NAME_PREFIX + INIT_FILE_NAME_SUFFIX; /** *

{@link Set} of file types.

@@ -126,11 +141,21 @@ private Build resolve(final BuildFile file, final OutputStream outputStream) thr connector.useInstallation(installation.toFile()); }); try (var connection = connector.connect()) { - connection.newBuild() - .forTasks("repositories", "dependencies") - .withArguments("--init-script=" + getClass().getClassLoader().getResource(INIT_FILE_NAME)) - .setStandardOutput(outputStream) - .run(); + final var initTempFile = Files.createTempFile(INIT_FILE_NAME_PREFIX, INIT_FILE_NAME_SUFFIX); + try { + Files.copy( + Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(INIT_FILE_NAME)), + initTempFile, + StandardCopyOption.REPLACE_EXISTING + ); + connection.newBuild() + .forTasks("repositories", "dependencies") + .withArguments("--init-script=" + initTempFile) + .setStandardOutput(outputStream) + .run(); + } finally { + Files.delete(initTempFile); + } } catch (final GradleConnectionException e) { throw new BuildResolveException(e); } finally { diff --git a/src/main/java/com/github/alexisjehan/mvncheck/core/util/MavenUtils.java b/src/main/java/com/github/alexisjehan/mvncheck/core/util/MavenUtils.java index c5515dc..298f961 100644 --- a/src/main/java/com/github/alexisjehan/mvncheck/core/util/MavenUtils.java +++ b/src/main/java/com/github/alexisjehan/mvncheck/core/util/MavenUtils.java @@ -25,8 +25,6 @@ import com.github.alexisjehan.javanilla.lang.Strings; import com.github.alexisjehan.javanilla.misc.quality.Ensure; -import com.google.inject.Guice; -import com.google.inject.Injector; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.apache.maven.repository.internal.MavenRepositorySystemUtils; @@ -42,6 +40,9 @@ import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.impl.RemoteRepositoryManager; +import org.eclipse.aether.internal.impl.DefaultChecksumPolicyProvider; +import org.eclipse.aether.internal.impl.DefaultRemoteRepositoryManager; +import org.eclipse.aether.internal.impl.DefaultUpdatePolicyAnalyzer; import org.eclipse.aether.repository.AuthenticationSelector; import org.eclipse.aether.repository.LocalRepository; import org.eclipse.aether.repository.MirrorSelector; @@ -50,14 +51,13 @@ import org.eclipse.aether.repository.RemoteRepository; import org.eclipse.aether.repository.RepositoryPolicy; import org.eclipse.aether.spi.locator.ServiceLocator; +import org.eclipse.aether.supplier.RepositorySystemSupplier; import org.eclipse.aether.util.repository.AuthenticationBuilder; import org.eclipse.aether.util.repository.ConservativeAuthenticationSelector; import org.eclipse.aether.util.repository.ConservativeProxySelector; import org.eclipse.aether.util.repository.DefaultAuthenticationSelector; import org.eclipse.aether.util.repository.DefaultMirrorSelector; import org.eclipse.aether.util.repository.DefaultProxySelector; -import org.eclipse.sisu.launch.Main; -import org.eclipse.sisu.space.BeanScanning; import org.sonatype.plexus.components.cipher.DefaultPlexusCipher; import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher; @@ -121,10 +121,10 @@ public final class MavenUtils { private static final Logger logger = LogManager.getLogger(MethodHandles.lookup().lookupClass()); /** - *

Dependency injector.

- * @since 1.1.0 + *

Repository system supplier.

+ * @since 1.7.0 */ - private static final Injector injector = Guice.createInjector(Main.wire(BeanScanning.INDEX)); + private static final RepositorySystemSupplier repositorySystemSupplier = new RepositorySystemSupplier(); /** *

Constructor.

@@ -247,7 +247,7 @@ public static RepositorySystem makeRepositorySystem(final ServiceLocator service * @since 1.1.0 */ public static RepositorySystem makeRepositorySystem() { - return injector.getInstance(RepositorySystem.class); + return repositorySystemSupplier.get(); } /** @@ -270,7 +270,10 @@ public static RemoteRepositoryManager makeRemoteRepositoryManager(final ServiceL * @since 1.1.0 */ public static RemoteRepositoryManager makeRemoteRepositoryManager() { - return injector.getInstance(RemoteRepositoryManager.class); + return new DefaultRemoteRepositoryManager( + new DefaultUpdatePolicyAnalyzer(), + new DefaultChecksumPolicyProvider() + ); } /**