proxy();
-
- @Description("The repositories for resolving plugins and their dependencies.")
- Repositories repositories();
-
+public interface CliConfiguration extends Configuration, ArtifactResolverConfiguration {
}
diff --git a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/task/AbstractStoreTask.java b/cli/application/src/main/java/com/buschmais/jqassistant/commandline/task/AbstractStoreTask.java
index 799b550340..7a3681609d 100644
--- a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/task/AbstractStoreTask.java
+++ b/cli/application/src/main/java/com/buschmais/jqassistant/commandline/task/AbstractStoreTask.java
@@ -6,7 +6,7 @@
import com.buschmais.jqassistant.commandline.CliConfigurationException;
import com.buschmais.jqassistant.commandline.CliExecutionException;
import com.buschmais.jqassistant.commandline.configuration.CliConfiguration;
-import com.buschmais.jqassistant.core.runtime.api.configuration.ConfigurationBuilder;
+import com.buschmais.jqassistant.core.shared.configuration.ConfigurationBuilder;
import com.buschmais.jqassistant.core.store.api.Store;
import com.buschmais.jqassistant.core.store.api.configuration.Embedded;
diff --git a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/task/EffectiveConfigurationTask.java b/cli/application/src/main/java/com/buschmais/jqassistant/commandline/task/EffectiveConfigurationTask.java
index 160870c5b7..9820b25a4e 100644
--- a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/task/EffectiveConfigurationTask.java
+++ b/cli/application/src/main/java/com/buschmais/jqassistant/commandline/task/EffectiveConfigurationTask.java
@@ -4,7 +4,7 @@
import com.buschmais.jqassistant.commandline.CliExecutionException;
import com.buschmais.jqassistant.commandline.configuration.CliConfiguration;
-import com.buschmais.jqassistant.core.runtime.api.configuration.ConfigurationSerializer;
+import com.buschmais.jqassistant.core.shared.configuration.ConfigurationSerializer;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.cli.Option;
diff --git a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/task/ScanTask.java b/cli/application/src/main/java/com/buschmais/jqassistant/commandline/task/ScanTask.java
index 24cbbd4bd3..f10a9e6d6b 100644
--- a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/task/ScanTask.java
+++ b/cli/application/src/main/java/com/buschmais/jqassistant/commandline/task/ScanTask.java
@@ -9,7 +9,6 @@
import com.buschmais.jqassistant.commandline.CliConfigurationException;
import com.buschmais.jqassistant.commandline.CliExecutionException;
import com.buschmais.jqassistant.commandline.configuration.CliConfiguration;
-import com.buschmais.jqassistant.core.runtime.api.configuration.ConfigurationBuilder;
import com.buschmais.jqassistant.core.scanner.api.Scanner;
import com.buschmais.jqassistant.core.scanner.api.ScannerContext;
import com.buschmais.jqassistant.core.scanner.api.Scope;
@@ -17,6 +16,7 @@
import com.buschmais.jqassistant.core.scanner.api.configuration.Include;
import com.buschmais.jqassistant.core.scanner.impl.ScannerContextImpl;
import com.buschmais.jqassistant.core.scanner.impl.ScannerImpl;
+import com.buschmais.jqassistant.core.shared.configuration.ConfigurationBuilder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.cli.CommandLine;
diff --git a/cli/application/src/test/java/com/buschmais/jqassistant/commandline/task/ServerTaskTest.java b/cli/application/src/test/java/com/buschmais/jqassistant/commandline/task/ServerTaskTest.java
index 1db4c79e8c..f65103bbd3 100644
--- a/cli/application/src/test/java/com/buschmais/jqassistant/commandline/task/ServerTaskTest.java
+++ b/cli/application/src/test/java/com/buschmais/jqassistant/commandline/task/ServerTaskTest.java
@@ -5,9 +5,9 @@
import com.buschmais.jqassistant.commandline.CliExecutionException;
import com.buschmais.jqassistant.commandline.configuration.CliConfiguration;
-import com.buschmais.jqassistant.core.runtime.api.configuration.ConfigurationBuilder;
import com.buschmais.jqassistant.core.runtime.api.plugin.PluginRepository;
import com.buschmais.jqassistant.core.shared.artifact.ArtifactProvider;
+import com.buschmais.jqassistant.core.shared.configuration.ConfigurationBuilder;
import com.buschmais.jqassistant.core.store.impl.EmbeddedGraphStore;
import com.buschmais.jqassistant.neo4j.embedded.EmbeddedNeo4jServer;
import com.buschmais.jqassistant.neo4j.embedded.api.configuration.Server;
diff --git a/cli/test/src/test/java/com/buschmais/jqassistant/commandline/test/AbstractCLIIT.java b/cli/test/src/test/java/com/buschmais/jqassistant/commandline/test/AbstractCLIIT.java
index 865553a7e3..ebd7a4eb40 100644
--- a/cli/test/src/test/java/com/buschmais/jqassistant/commandline/test/AbstractCLIIT.java
+++ b/cli/test/src/test/java/com/buschmais/jqassistant/commandline/test/AbstractCLIIT.java
@@ -9,14 +9,14 @@
import com.buschmais.jqassistant.commandline.Task;
import com.buschmais.jqassistant.commandline.configuration.CliConfiguration;
-import com.buschmais.jqassistant.commandline.plugin.ArtifactProviderFactory;
-import com.buschmais.jqassistant.core.runtime.api.configuration.ConfigurationBuilder;
-import com.buschmais.jqassistant.core.runtime.api.configuration.ConfigurationMappingLoader;
+import com.buschmais.jqassistant.core.resolver.api.ArtifactProviderFactory;
import com.buschmais.jqassistant.core.runtime.api.plugin.PluginClassLoader;
import com.buschmais.jqassistant.core.runtime.api.plugin.PluginRepository;
import com.buschmais.jqassistant.core.runtime.impl.plugin.PluginConfigurationReaderImpl;
import com.buschmais.jqassistant.core.runtime.impl.plugin.PluginRepositoryImpl;
import com.buschmais.jqassistant.core.shared.artifact.ArtifactProvider;
+import com.buschmais.jqassistant.core.shared.configuration.ConfigurationBuilder;
+import com.buschmais.jqassistant.core.shared.configuration.ConfigurationMappingLoader;
import com.buschmais.jqassistant.core.store.api.Store;
import com.buschmais.jqassistant.core.store.api.StoreFactory;
diff --git a/core/artifact-resolver/pom.xml b/core/artifact-resolver/pom.xml
new file mode 100644
index 0000000000..33a172c310
--- /dev/null
+++ b/core/artifact-resolver/pom.xml
@@ -0,0 +1,98 @@
+
+ 4.0.0
+
+
+ com.buschmais.jqassistant.core
+ parent
+ 2.6.0-SNAPSHOT
+
+
+ artifact-resolver
+
+ jQAssistant Artifact Provider
+ https://jqassistant.org/
+
+
+ Provides an implementation for an artifact provider.
+
+
+
+
+ com.buschmais.jqassistant.core
+ shared
+ ${project.version}
+
+
+
+ org.apache.maven
+ maven-settings-builder
+ ${maven.version}
+
+
+
+ org.apache.maven.resolver
+ maven-resolver-impl
+
+
+ org.apache.maven.resolver
+ maven-resolver-connector-basic
+
+
+ org.apache.maven.resolver
+ maven-resolver-transport-file
+
+
+ org.apache.maven.resolver
+ maven-resolver-transport-http
+
+
+ org.apache.maven
+ maven-resolver-provider
+ ${maven.version}
+
+
+ org.apache.maven.resolver
+ *
+
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+ org.junit.jupiter
+ junit-jupiter-engine
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter-params
+ test
+
+
+ org.junit.vintage
+ junit-vintage-engine
+ test
+
+
+ org.mockito
+ mockito-junit-jupiter
+
+
+ org.assertj
+ assertj-core
+
+
+ org.slf4j
+ slf4j-simple
+
+
+
+
diff --git a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/plugin/ArtifactProviderFactory.java b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/api/ArtifactProviderFactory.java
similarity index 70%
rename from cli/application/src/main/java/com/buschmais/jqassistant/commandline/plugin/ArtifactProviderFactory.java
rename to core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/api/ArtifactProviderFactory.java
index 97a9ba1b3e..adf04ed67c 100644
--- a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/plugin/ArtifactProviderFactory.java
+++ b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/api/ArtifactProviderFactory.java
@@ -1,4 +1,4 @@
-package com.buschmais.jqassistant.commandline.plugin;
+package com.buschmais.jqassistant.core.resolver.api;
import java.io.File;
import java.util.HashMap;
@@ -6,11 +6,10 @@
import java.util.Map;
import java.util.Optional;
-import com.buschmais.jqassistant.commandline.configuration.*;
-import com.buschmais.jqassistant.commandline.configuration.Proxy;
-import com.buschmais.jqassistant.core.runtime.api.plugin.PluginResolver;
-import com.buschmais.jqassistant.core.runtime.impl.plugin.AetherArtifactProvider;
-import com.buschmais.jqassistant.core.shared.configuration.Plugin;
+import com.buschmais.jqassistant.core.resolver.configuration.*;
+import com.buschmais.jqassistant.core.resolver.configuration.Proxy;
+import com.buschmais.jqassistant.core.shared.aether.AetherArtifactProvider;
+import com.buschmais.jqassistant.core.shared.aether.configuration.Plugin;
import lombok.extern.slf4j.Slf4j;
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
@@ -34,10 +33,11 @@
import static java.util.Optional.of;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
-import static org.eclipse.aether.repository.RepositoryPolicy.*;
+import static org.eclipse.aether.repository.RepositoryPolicy.CHECKSUM_POLICY_WARN;
+import static org.eclipse.aether.repository.RepositoryPolicy.UPDATE_POLICY_DAILY;
/**
- * Factory for the {@link PluginResolver} to be used in standalone in the CLI.
+ * Factory for the {@link AetherArtifactProvider} to be used in standalone in the CLI.
*/
@Slf4j
public class ArtifactProviderFactory {
@@ -99,17 +99,17 @@ public ArtifactProviderFactory(File userHome) {
}
/**
- * Creates a {@link PluginResolver} using the given {@link CliConfiguration} providing the required {@link Plugin}s and {@link Repositories}
+ * Creates a {@link AetherArtifactProvider} using the given {@link ArtifactResolverConfiguration} providing the required {@link Plugin}s and {@link Repositories}
*
* The default local repository is ~/.jqassistant/repository.
*
* If no remote repository is specified the resolver will use Maven Central.
*
* @param configuration
- * The {@link CliConfiguration}.
- * @return The {@link PluginResolver}.
+ * The {@link ArtifactResolverConfiguration}.
+ * @return The {@link AetherArtifactProvider}.
*/
- public AetherArtifactProvider create(CliConfiguration configuration) {
+ public AetherArtifactProvider create(ArtifactResolverConfiguration configuration) {
Repositories repositories = configuration.repositories();
File localRepository = getLocalRepository(repositories);
Optional proxy = getProxy(configuration.proxy());
@@ -119,16 +119,16 @@ public AetherArtifactProvider create(CliConfiguration configuration) {
RepositorySystem repositorySystem = newRepositorySystem();
log.info("Local repository: {}", localRepository);
log.info("Remote repositories: {}", remoteRepositories.stream()
- .map(repository -> {
- org.eclipse.aether.repository.Proxy repositoryProxy = repository.getProxy();
- List mirroredRepositories = repository.getMirroredRepositories();
- return String.format("'%s (%s%s%s)'", repository.getId(), repository.getUrl(), !mirroredRepositories.isEmpty() ?
- String.format(", mirror of %s", mirroredRepositories.stream()
- .map(r -> r.getId())
- .collect(joining(", "))) :
- "", repositoryProxy != null ? String.format(" via proxy %s:%d", repositoryProxy.getHost(), repositoryProxy.getPort()) : "");
- })
- .collect(joining(", ")));
+ .map(repository -> {
+ org.eclipse.aether.repository.Proxy repositoryProxy = repository.getProxy();
+ List mirroredRepositories = repository.getMirroredRepositories();
+ return String.format("'%s (%s%s%s)'", repository.getId(), repository.getUrl(), !mirroredRepositories.isEmpty() ?
+ String.format(", mirror of %s", mirroredRepositories.stream()
+ .map(r -> r.getId())
+ .collect(joining(", "))) :
+ "", repositoryProxy != null ? String.format(" via proxy %s:%d", repositoryProxy.getHost(), repositoryProxy.getPort()) : "");
+ })
+ .collect(joining(", ")));
RepositorySystemSession session = newRepositorySystemSession(repositories, repositorySystem, localRepository, mirrorSelector, proxySelector);
return new AetherArtifactProvider(repositorySystem, session, remoteRepositories);
@@ -138,41 +138,41 @@ public AetherArtifactProvider create(CliConfiguration configuration) {
* Determine the local repository to use.
*
* @param repositories
- * The {@link Repositories} configuration.
+ * The {@link Repositories} configuration.
* @return The local repository.
*/
private File getLocalRepository(Repositories repositories) {
// determine local repository
return repositories.local()
- .orElseGet(() -> {
- File repository = new File(jqassistantUserDir, "repository");
- repository.mkdirs();
- return repository;
- });
+ .orElseGet(() -> {
+ File repository = new File(jqassistantUserDir, "repository");
+ repository.mkdirs();
+ return repository;
+ });
}
private Optional getProxy(Optional proxy) {
return proxy.map(p -> {
String protocol = p.protocol()
- .orElse("https");
+ .orElse("https");
String host = p.host();
Integer port = p.port();
AuthenticationBuilder authBuilder = new AuthenticationBuilder();
p.username()
- .ifPresent(authBuilder::addUsername);
+ .ifPresent(authBuilder::addUsername);
p.password()
- .ifPresent(authBuilder::addPassword);
+ .ifPresent(authBuilder::addPassword);
return new org.eclipse.aether.repository.Proxy(protocol, host, port, authBuilder.build());
});
}
- private ProxySelector getProxySelector(CliConfiguration configuration, Optional optionalProxy) {
+ private ProxySelector getProxySelector(ArtifactResolverConfiguration configuration, Optional optionalProxy) {
DefaultProxySelector proxySelector = new DefaultProxySelector();
optionalProxy.ifPresent(proxy -> proxySelector.add(proxy, configuration.proxy()
- .map(proxyConfiguration -> proxyConfiguration.nonProxyHosts()
- .orElse(null))
- .orElse(null)));
+ .map(proxyConfiguration -> proxyConfiguration.nonProxyHosts()
+ .orElse(null))
+ .orElse(null)));
return proxySelector;
}
@@ -180,11 +180,11 @@ private ProxySelector getProxySelector(CliConfiguration configuration, Optional<
* Determines the remote repositories to use, using Maven Central as fallback.
*
* @param repositories
- * The {@link Repositories} configuration.
+ * The {@link Repositories} configuration.
* @param proxySelector
- * The {@link ProxySelector}.
+ * The {@link ProxySelector}.
* @param mirrorSelector
- * The {@link MirrorSelector}.
+ * The {@link MirrorSelector}.
* @return The list of configured {@link RemoteRepository}s.
*/
private List getRemoteRepositories(Repositories repositories, ProxySelector proxySelector, Optional mirrorSelector) {
@@ -194,16 +194,16 @@ private List getRemoteRepositories(Repositories repositories,
// Add configured remotes
remotes.putAll(repositories.remotes());
return remotes.entrySet()
- .stream()
- .map(remoteEntry -> getRemoteRepository(remoteEntry.getKey(), remoteEntry.getValue(), proxySelector))
- // apply any configured mirrors to the remote repository
- .map(remoteRepository -> mirrorSelector.map(selector -> selectMirror(remoteRepository, selector, repositories.mirrors(), proxySelector))
- .orElse(remoteRepository))
- .collect(toList());
+ .stream()
+ .map(remoteEntry -> getRemoteRepository(remoteEntry.getKey(), remoteEntry.getValue(), proxySelector))
+ // apply any configured mirrors to the remote repository
+ .map(remoteRepository -> mirrorSelector.map(selector -> selectMirror(remoteRepository, selector, repositories.mirrors(), proxySelector))
+ .orElse(remoteRepository))
+ .collect(toList());
}
private static RemoteRepository selectMirror(RemoteRepository remoteRepository, MirrorSelector selector, Map mirrors,
- ProxySelector proxySelector) {
+ ProxySelector proxySelector) {
RemoteRepository mirrorRepository = selector.getMirror(remoteRepository);
if (mirrorRepository == null) {
return remoteRepository;
@@ -214,9 +214,9 @@ private static RemoteRepository selectMirror(RemoteRepository remoteRepository,
private static RemoteRepository getRemoteRepository(String id, Remote remote, ProxySelector proxySelector) {
RemoteRepository remoteRepository = new RemoteRepository.Builder(id, REPOSITORY_LAYOUT_DEFAULT, remote.url()) //
- .setReleasePolicy(getRepositoryPolicy(remote.releases()))
- .setSnapshotPolicy(getRepositoryPolicy(remote.snapshots()))
- .build();
+ .setReleasePolicy(getRepositoryPolicy(remote.releases()))
+ .setSnapshotPolicy(getRepositoryPolicy(remote.snapshots()))
+ .build();
return getRemoteRepository(remoteRepository, proxySelector, remote.username(), remote.password());
}
@@ -225,14 +225,14 @@ private static RepositoryPolicy getRepositoryPolicy(Policy policy) {
}
private static RemoteRepository getRemoteRepository(RemoteRepository remoteRepository, ProxySelector proxySelector, Optional optionalUsername,
- Optional optionalPassword) {
+ Optional optionalPassword) {
AuthenticationBuilder authBuilder = new AuthenticationBuilder();
optionalUsername.ifPresent(authBuilder::addUsername);
optionalPassword.ifPresent(authBuilder::addPassword);
org.eclipse.aether.repository.Proxy proxy = proxySelector.getProxy(remoteRepository);
return new RemoteRepository.Builder(remoteRepository).setProxy(proxy)
- .setAuthentication(authBuilder.build())
- .build();
+ .setAuthentication(authBuilder.build())
+ .build();
}
/**
@@ -252,17 +252,17 @@ private RepositorySystem newRepositorySystem() {
* Creates a new {@link RepositorySystemSession}.
*
* @param repositories
- * The {@link Repositories}
+ * The {@link Repositories}
* @param system
- * the {@link RepositorySystem}
+ * the {@link RepositorySystem}
* @param mirrorSelector
- * The optional {@link MirrorSelector}.
+ * The optional {@link MirrorSelector}.
* @param proxySelector
- * The {@link ProxySelector}.
+ * The {@link ProxySelector}.
* @return a new {@link RepositorySystemSession}.
*/
private RepositorySystemSession newRepositorySystemSession(Repositories repositories, RepositorySystem system, File localDirectory,
- Optional mirrorSelector, ProxySelector proxySelector) {
+ Optional mirrorSelector, ProxySelector proxySelector) {
DefaultRepositorySystemSession session = MavenRepositorySystemUtils.newSession();
session.setTransferListener(new TransferListener());
LocalRepository localRepo = new LocalRepository(localDirectory);
@@ -270,18 +270,18 @@ private RepositorySystemSession newRepositorySystemSession(Repositories reposito
session.setProxySelector(proxySelector);
mirrorSelector.ifPresent(session::setMirrorSelector);
session.setIgnoreArtifactDescriptorRepositories(repositories.ignoreTransitiveRepositories()
- .orElse(true));
+ .orElse(true));
return session;
}
private Optional getMirrorSelector(Repositories repositories) {
if (repositories.mirrors()
- .isEmpty()) {
+ .isEmpty()) {
return empty();
}
DefaultMirrorSelector mirrorSelector = new DefaultMirrorSelector();
for (Map.Entry entry : repositories.mirrors()
- .entrySet()) {
+ .entrySet()) {
String id = entry.getKey();
Mirror mirror = entry.getValue();
mirrorSelector.add(id, mirror.url(), null, false, false, mirror.mirrorOf(), null);
@@ -296,15 +296,15 @@ private static class TransferListener extends AbstractTransferListener {
@Override
public void transferStarted(TransferEvent transferEvent) {
log.info("Downloading '{}{}'.", transferEvent.getResource()
- .getRepositoryUrl(), transferEvent.getResource()
- .getResourceName());
+ .getRepositoryUrl(), transferEvent.getResource()
+ .getResourceName());
}
@Override
public void transferSucceeded(TransferEvent transferEvent) {
log.info("Finished download of '{}{}'.", transferEvent.getResource()
- .getRepositoryUrl(), transferEvent.getResource()
- .getResourceName());
+ .getRepositoryUrl(), transferEvent.getResource()
+ .getResourceName());
}
}
}
diff --git a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/MavenSettingsConfigSourceBuilder.java b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/api/MavenSettingsConfigSourceBuilder.java
similarity index 75%
rename from cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/MavenSettingsConfigSourceBuilder.java
rename to core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/api/MavenSettingsConfigSourceBuilder.java
index 4521684119..2443511c5b 100644
--- a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/MavenSettingsConfigSourceBuilder.java
+++ b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/api/MavenSettingsConfigSourceBuilder.java
@@ -1,40 +1,35 @@
-package com.buschmais.jqassistant.commandline.configuration;
+package com.buschmais.jqassistant.core.resolver.api;
import java.io.File;
import java.util.*;
-import com.buschmais.jqassistant.commandline.CliConfigurationException;
+import com.buschmais.jqassistant.core.resolver.configuration.ArtifactResolverConfiguration;
+import com.buschmais.jqassistant.core.resolver.configuration.Policy;
+import com.buschmais.jqassistant.core.resolver.configuration.Remote;
+import com.buschmais.jqassistant.core.resolver.configuration.Repositories;
import io.smallrye.config.PropertiesConfigSource;
+import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.maven.settings.*;
-import org.apache.maven.settings.Mirror;
-import org.apache.maven.settings.Proxy;
import org.apache.maven.settings.building.DefaultSettingsBuilderFactory;
import org.apache.maven.settings.building.DefaultSettingsBuildingRequest;
import org.apache.maven.settings.building.SettingsBuildingException;
import org.apache.maven.settings.building.SettingsBuildingRequest;
import org.eclipse.microprofile.config.spi.ConfigSource;
-import static com.buschmais.jqassistant.commandline.configuration.CliConfiguration.PROXY;
-import static com.buschmais.jqassistant.commandline.configuration.Mirror.MIRROR_OF;
-import static com.buschmais.jqassistant.commandline.configuration.Mirror.URL;
-import static com.buschmais.jqassistant.commandline.configuration.Proxy.*;
-import static com.buschmais.jqassistant.core.runtime.api.configuration.Configuration.PREFIX;
import static java.util.stream.Collectors.toList;
-import static lombok.AccessLevel.PRIVATE;
@Slf4j
-@NoArgsConstructor(access = PRIVATE)
+@NoArgsConstructor(access = AccessLevel.PRIVATE)
public class MavenSettingsConfigSourceBuilder {
private static final String USER_MAVEN_SETTINGS = ".m2/settings.xml";
private static final String DEFAULT_LOCAL_REPOSITORY = ".m2/repository";
- public static ConfigSource createMavenSettingsConfigSource(File userHome, Optional mavenSettingsFile, List profiles)
- throws CliConfigurationException {
+ public static ConfigSource createMavenSettingsConfigSource(File userHome, Optional mavenSettingsFile, List profiles) {
Map properties = new HashMap<>();
File settingsFile = mavenSettingsFile.orElseGet(() -> new File(userHome, USER_MAVEN_SETTINGS));
@@ -69,10 +64,13 @@ private static void applyMirrors(Map properties, Settings settin
for (Mirror mirror : settings.getMirrors()) {
String id = mirror.getId();
if (id != null) {
- put(mirror.getUrl(), properties, com.buschmais.jqassistant.commandline.configuration.Mirror.PREFIX, id, URL);
- put(mirror.getMirrorOf(), properties, com.buschmais.jqassistant.commandline.configuration.Mirror.PREFIX, id, MIRROR_OF);
- applyServerCredentials(id, settings, properties, com.buschmais.jqassistant.commandline.configuration.Mirror.PREFIX,
- com.buschmais.jqassistant.commandline.configuration.Mirror.USERNAME, com.buschmais.jqassistant.commandline.configuration.Mirror.PASSWORD);
+ put(mirror.getUrl(), properties, com.buschmais.jqassistant.core.resolver.configuration.Mirror.PREFIX, id,
+ com.buschmais.jqassistant.core.resolver.configuration.Mirror.URL);
+ put(mirror.getMirrorOf(), properties, com.buschmais.jqassistant.core.resolver.configuration.Mirror.PREFIX, id,
+ com.buschmais.jqassistant.core.resolver.configuration.Mirror.MIRROR_OF);
+ applyServerCredentials(id, settings, properties, com.buschmais.jqassistant.core.resolver.configuration.Mirror.PREFIX,
+ com.buschmais.jqassistant.core.resolver.configuration.Mirror.USERNAME,
+ com.buschmais.jqassistant.core.resolver.configuration.Mirror.PASSWORD);
} else {
log.warn("Cannot configure mirror from Maven settings without id (url={}).", mirror.getUrl());
}
@@ -85,12 +83,18 @@ private static void applyProxy(Map properties, Settings settings
.filter(Proxy::isActive)
.findFirst()
.ifPresent(proxy -> {
- put(proxy.getProtocol(), properties, PREFIX, PROXY, PROTOCOL);
- put(proxy.getHost(), properties, PREFIX, PROXY, HOST);
- put(Integer.toString(proxy.getPort()), properties, PREFIX, PROXY, PORT);
- put(proxy.getUsername(), properties, PREFIX, PROXY, USERNAME);
- put(proxy.getPassword(), properties, PREFIX, PROXY, PASSWORD);
- put(proxy.getNonProxyHosts(), properties, PREFIX, PROXY, NON_PROXY_HOSTS);
+ put(proxy.getProtocol(), properties, ArtifactResolverConfiguration.PREFIX, ArtifactResolverConfiguration.PROXY,
+ com.buschmais.jqassistant.core.resolver.configuration.Proxy.PROTOCOL);
+ put(proxy.getHost(), properties, ArtifactResolverConfiguration.PREFIX, ArtifactResolverConfiguration.PROXY,
+ com.buschmais.jqassistant.core.resolver.configuration.Proxy.HOST);
+ put(Integer.toString(proxy.getPort()), properties, ArtifactResolverConfiguration.PREFIX, ArtifactResolverConfiguration.PROXY,
+ com.buschmais.jqassistant.core.resolver.configuration.Proxy.PORT);
+ put(proxy.getUsername(), properties, ArtifactResolverConfiguration.PREFIX, ArtifactResolverConfiguration.PROXY,
+ com.buschmais.jqassistant.core.resolver.configuration.Proxy.USERNAME);
+ put(proxy.getPassword(), properties, ArtifactResolverConfiguration.PREFIX, ArtifactResolverConfiguration.PROXY,
+ com.buschmais.jqassistant.core.resolver.configuration.Proxy.PASSWORD);
+ put(proxy.getNonProxyHosts(), properties, ArtifactResolverConfiguration.PREFIX, ArtifactResolverConfiguration.PROXY,
+ com.buschmais.jqassistant.core.resolver.configuration.Proxy.NON_PROXY_HOSTS);
});
}
@@ -167,7 +171,7 @@ private static void applyServerCredentials(String serverId, Settings settings, M
}
}
- private static Settings loadMavenSettings(File settingsFile) throws CliConfigurationException {
+ private static Settings loadMavenSettings(File settingsFile) throws IllegalStateException {
log.info("Using Maven settings from '{}'.", settingsFile);
SettingsBuildingRequest request = new DefaultSettingsBuildingRequest();
request.setUserSettingsFile(settingsFile);
@@ -177,7 +181,7 @@ private static Settings loadMavenSettings(File settingsFile) throws CliConfigura
.build(request)
.getEffectiveSettings();
} catch (SettingsBuildingException ex) {
- throw new CliConfigurationException("Failed to build settings from " + settingsFile, ex);
+ throw new IllegalStateException("Failed to build settings from " + settingsFile, ex);
}
}
}
diff --git a/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/ArtifactResolverConfiguration.java b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/ArtifactResolverConfiguration.java
new file mode 100644
index 0000000000..432b7be55f
--- /dev/null
+++ b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/ArtifactResolverConfiguration.java
@@ -0,0 +1,23 @@
+package com.buschmais.jqassistant.core.resolver.configuration;
+
+import java.util.Optional;
+
+import com.buschmais.jqassistant.core.shared.annotation.Description;
+import com.buschmais.jqassistant.core.shared.configuration.ConfigurationMappingLoader;
+
+import io.smallrye.config.ConfigMapping;
+
+@ConfigMapping(prefix = ConfigurationMappingLoader.PREFIX)
+public interface ArtifactResolverConfiguration {
+
+ String PREFIX = "jqassistant";
+
+ String PROXY = "proxy";
+
+ @Description("The proxy to use for connecting to repositories.")
+ Optional proxy();
+
+ @Description("The repositories for resolving plugins and their dependencies.")
+ Repositories repositories();
+
+}
diff --git a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Mirror.java b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Mirror.java
similarity index 93%
rename from cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Mirror.java
rename to core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Mirror.java
index 353a037af0..bd0a44e6e7 100644
--- a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Mirror.java
+++ b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Mirror.java
@@ -1,4 +1,4 @@
-package com.buschmais.jqassistant.commandline.configuration;
+package com.buschmais.jqassistant.core.resolver.configuration;
import java.util.Optional;
diff --git a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Policy.java b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Policy.java
similarity index 88%
rename from cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Policy.java
rename to core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Policy.java
index 12cf450e7c..7922a5aeea 100644
--- a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Policy.java
+++ b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Policy.java
@@ -1,4 +1,4 @@
-package com.buschmais.jqassistant.commandline.configuration;
+package com.buschmais.jqassistant.core.resolver.configuration;
import com.buschmais.jqassistant.core.shared.annotation.Description;
diff --git a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Proxy.java b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Proxy.java
similarity index 92%
rename from cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Proxy.java
rename to core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Proxy.java
index 7996cb862a..6f9e3e3416 100644
--- a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Proxy.java
+++ b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Proxy.java
@@ -1,4 +1,4 @@
-package com.buschmais.jqassistant.commandline.configuration;
+package com.buschmais.jqassistant.core.resolver.configuration;
import java.util.Optional;
diff --git a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Remote.java b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Remote.java
similarity index 93%
rename from cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Remote.java
rename to core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Remote.java
index 6fe1ae9bc4..636a2bc307 100644
--- a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Remote.java
+++ b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Remote.java
@@ -1,4 +1,4 @@
-package com.buschmais.jqassistant.commandline.configuration;
+package com.buschmais.jqassistant.core.resolver.configuration;
import java.util.Optional;
diff --git a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Repositories.java b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Repositories.java
similarity index 93%
rename from cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Repositories.java
rename to core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Repositories.java
index 4114e369fb..a8693d71f3 100644
--- a/cli/application/src/main/java/com/buschmais/jqassistant/commandline/configuration/Repositories.java
+++ b/core/artifact-resolver/src/main/java/com/buschmais/jqassistant/core/resolver/configuration/Repositories.java
@@ -1,4 +1,4 @@
-package com.buschmais.jqassistant.commandline.configuration;
+package com.buschmais.jqassistant.core.resolver.configuration;
import java.io.File;
import java.util.Map;
diff --git a/cli/application/src/test/java/com/buschmais/jqassistant/commandline/plugin/ArtifactProviderFactoryTest.java b/core/artifact-resolver/src/test/java/com/buschmais/jqassistant/core/resolver/api/ArtifactProviderFactoryTest.java
similarity index 86%
rename from cli/application/src/test/java/com/buschmais/jqassistant/commandline/plugin/ArtifactProviderFactoryTest.java
rename to core/artifact-resolver/src/test/java/com/buschmais/jqassistant/core/resolver/api/ArtifactProviderFactoryTest.java
index d332126965..c4d32ccbc7 100644
--- a/cli/application/src/test/java/com/buschmais/jqassistant/commandline/plugin/ArtifactProviderFactoryTest.java
+++ b/core/artifact-resolver/src/test/java/com/buschmais/jqassistant/core/resolver/api/ArtifactProviderFactoryTest.java
@@ -1,4 +1,4 @@
-package com.buschmais.jqassistant.commandline.plugin;
+package com.buschmais.jqassistant.core.resolver.api;
import java.io.File;
import java.net.URL;
@@ -6,11 +6,11 @@
import java.util.Map;
import java.util.function.Consumer;
-import com.buschmais.jqassistant.commandline.configuration.CliConfiguration;
-import com.buschmais.jqassistant.commandline.configuration.Mirror;
-import com.buschmais.jqassistant.commandline.configuration.Proxy;
-import com.buschmais.jqassistant.commandline.configuration.Repositories;
-import com.buschmais.jqassistant.core.runtime.impl.plugin.AetherArtifactProvider;
+import com.buschmais.jqassistant.core.resolver.configuration.ArtifactResolverConfiguration;
+import com.buschmais.jqassistant.core.resolver.configuration.Mirror;
+import com.buschmais.jqassistant.core.resolver.configuration.Proxy;
+import com.buschmais.jqassistant.core.resolver.configuration.Repositories;
+import com.buschmais.jqassistant.core.shared.aether.AetherArtifactProvider;
import org.eclipse.aether.repository.Authentication;
import org.eclipse.aether.repository.RemoteRepository;
@@ -20,8 +20,8 @@
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
-import static com.buschmais.jqassistant.commandline.plugin.ArtifactProviderFactory.MAVEN_CENTRAL_ID;
-import static com.buschmais.jqassistant.commandline.plugin.ArtifactProviderFactory.MAVEN_CENTRAL_URL;
+import static com.buschmais.jqassistant.core.resolver.api.ArtifactProviderFactory.MAVEN_CENTRAL_ID;
+import static com.buschmais.jqassistant.core.resolver.api.ArtifactProviderFactory.MAVEN_CENTRAL_URL;
import static java.util.Optional.of;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.doReturn;
@@ -33,7 +33,7 @@ class ArtifactProviderFactoryTest {
private ArtifactProviderFactory artifactProviderFactory;
@Mock
- private CliConfiguration configuration;
+ private ArtifactResolverConfiguration configuration;
@Mock
private Repositories repositories;
diff --git a/cli/application/src/test/java/com/buschmais/jqassistant/commandline/configuration/MavenSettingsConfigSourceBuilderTest.java b/core/artifact-resolver/src/test/java/com/buschmais/jqassistant/core/resolver/api/MavenSettingsConfigSourceBuilderTest.java
similarity index 83%
rename from cli/application/src/test/java/com/buschmais/jqassistant/commandline/configuration/MavenSettingsConfigSourceBuilderTest.java
rename to core/artifact-resolver/src/test/java/com/buschmais/jqassistant/core/resolver/api/MavenSettingsConfigSourceBuilderTest.java
index 7eaa005d07..7c8751c102 100644
--- a/cli/application/src/test/java/com/buschmais/jqassistant/commandline/configuration/MavenSettingsConfigSourceBuilderTest.java
+++ b/core/artifact-resolver/src/test/java/com/buschmais/jqassistant/core/resolver/api/MavenSettingsConfigSourceBuilderTest.java
@@ -1,4 +1,4 @@
-package com.buschmais.jqassistant.commandline.configuration;
+package com.buschmais.jqassistant.core.resolver.api;
import java.io.File;
import java.net.URL;
@@ -6,9 +6,11 @@
import java.util.Map;
import java.util.Optional;
-import com.buschmais.jqassistant.commandline.CliConfigurationException;
-import com.buschmais.jqassistant.core.runtime.api.configuration.ConfigurationMappingLoader;
+import com.buschmais.jqassistant.core.resolver.configuration.*;
+import com.buschmais.jqassistant.core.shared.configuration.ConfigurationMappingLoader;
+import io.smallrye.config.ConfigMapping;
+import io.smallrye.config.WithDefault;
import org.eclipse.microprofile.config.spi.ConfigSource;
import org.junit.jupiter.api.Test;
@@ -19,17 +21,24 @@
class MavenSettingsConfigSourceBuilderTest {
+ @ConfigMapping(prefix = ArtifactResolverConfiguration.PREFIX)
+ interface MavenConfiguration extends ArtifactResolverConfiguration {
+
+ @WithDefault("false")
+ boolean skip();
+
+ }
+
@Test
- void defaultMavenSettings() throws CliConfigurationException {
+ void defaultMavenSettings() {
URL userHomeUrl = MavenSettingsConfigSourceBuilderTest.class.getResource("/userhome");
File userHome = new File(userHomeUrl.getFile());
ConfigSource configSource = MavenSettingsConfigSourceBuilder.createMavenSettingsConfigSource(userHome, empty(), emptyList());
- CliConfiguration configuration = ConfigurationMappingLoader.builder(CliConfiguration.class)
+ MavenConfiguration configuration = ConfigurationMappingLoader.builder(MavenConfiguration.class)
.load(configSource);
- assertThat(configuration.skip()).isFalse();
Optional proxyOptional = configuration.proxy();
assertThat(proxyOptional).isPresent();
Proxy proxy = proxyOptional.get();
@@ -85,27 +94,27 @@ void defaultMavenSettings() throws CliConfigurationException {
}
@Test
- void userProfile() throws CliConfigurationException {
+ void userProfile() {
URL userHomeUrl = MavenSettingsConfigSourceBuilderTest.class.getResource("/userhome");
File userHome = new File(userHomeUrl.getFile());
ConfigSource configSource = MavenSettingsConfigSourceBuilder.createMavenSettingsConfigSource(userHome, empty(), List.of("user-profile"));
- CliConfiguration configuration = ConfigurationMappingLoader.builder(CliConfiguration.class)
+ MavenConfiguration configuration = ConfigurationMappingLoader.builder(MavenConfiguration.class)
.load(configSource);
assertThat(configuration.skip()).isTrue();
}
@Test
- void customMavenSettings() throws CliConfigurationException {
+ void customMavenSettings() {
URL userHomeUrl = MavenSettingsConfigSourceBuilderTest.class.getResource("/userhome");
File userHome = new File(userHomeUrl.getFile());
File customSettings = new File(userHome, "custom-maven-settings.xml");
ConfigSource configSource = MavenSettingsConfigSourceBuilder.createMavenSettingsConfigSource(userHome, of(customSettings), emptyList());
- CliConfiguration configuration = ConfigurationMappingLoader.builder(CliConfiguration.class)
+ MavenConfiguration configuration = ConfigurationMappingLoader.builder(MavenConfiguration.class)
.load(configSource);
Repositories repositories = configuration.repositories();
@@ -114,13 +123,13 @@ void customMavenSettings() throws CliConfigurationException {
}
@Test
- void customMavenSettingsWithoutLocalRepo() throws CliConfigurationException {
+ void customMavenSettingsWithoutLocalRepo() {
URL userHomeUrl = MavenSettingsConfigSourceBuilderTest.class.getResource("/userhome");
File userHome = new File(userHomeUrl.getFile());
File customSettings = new File(userHome, "custom-maven-settings-without-local-repo.xml");
ConfigSource configSource = MavenSettingsConfigSourceBuilder.createMavenSettingsConfigSource(userHome, of(customSettings), emptyList());
- CliConfiguration configuration = ConfigurationMappingLoader.builder(CliConfiguration.class)
+ MavenConfiguration configuration = ConfigurationMappingLoader.builder(MavenConfiguration.class)
.load(configSource);
Repositories repositories = configuration.repositories();
@@ -128,7 +137,7 @@ void customMavenSettingsWithoutLocalRepo() throws CliConfigurationException {
}
@Test
- void withoutMavenSettings() throws CliConfigurationException {
+ void withoutMavenSettings() {
File userHome = new File("invalid-userhome");
ConfigSource configSource = MavenSettingsConfigSourceBuilder.createMavenSettingsConfigSource(userHome, empty(), emptyList());
diff --git a/cli/application/src/test/resources/userhome/.m2/settings.xml b/core/artifact-resolver/src/test/resources/userhome/.m2/settings.xml
similarity index 100%
rename from cli/application/src/test/resources/userhome/.m2/settings.xml
rename to core/artifact-resolver/src/test/resources/userhome/.m2/settings.xml
diff --git a/cli/application/src/test/resources/userhome/custom-maven-settings-without-local-repo.xml b/core/artifact-resolver/src/test/resources/userhome/custom-maven-settings-without-local-repo.xml
similarity index 100%
rename from cli/application/src/test/resources/userhome/custom-maven-settings-without-local-repo.xml
rename to core/artifact-resolver/src/test/resources/userhome/custom-maven-settings-without-local-repo.xml
diff --git a/cli/application/src/test/resources/userhome/custom-maven-settings.xml b/core/artifact-resolver/src/test/resources/userhome/custom-maven-settings.xml
similarity index 100%
rename from cli/application/src/test/resources/userhome/custom-maven-settings.xml
rename to core/artifact-resolver/src/test/resources/userhome/custom-maven-settings.xml
diff --git a/core/pom.xml b/core/pom.xml
index f7b40923fc..da7d7d7815 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -61,14 +61,15 @@
+ analysis
+ artifact-resolver
neo4j
- schemata
shared
- rule
- report
- analysis
scanner
+ schemata
store
+ report
+ rule
runtime
test
diff --git a/core/runtime/pom.xml b/core/runtime/pom.xml
index 9533a7f71b..df10227a66 100644
--- a/core/runtime/pom.xml
+++ b/core/runtime/pom.xml
@@ -25,24 +25,17 @@
com.buschmais.jqassistant.core
report