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() + ); } /**