public static JavaArchive[] awaitability() { return Maven.resolver() .loadPomFromFile("pom.xml") .resolve("org.assertj:assertj-core", "com.jayway.awaitility:awaitility") .withTransitivity() .as(JavaArchive.class); }
public static File[] resolveDependencies(final String coords) { return Maven.resolver().loadPomFromFile("pom.xml") .resolve(coords) .withTransitivity().asFile(); } }
/** * Resolves the given artifact by it's name with help of maven build system. * * @param artifact the fully qualified artifact name * * @return the resolved files */ private File[] resolveArtifact(String artifact) { return Maven.resolver() .resolve(artifact) .withTransitivity() .asFile(); } }
public static File[] single(PomStrategy pomStrategy, String groupId, String artifactId) { return Maven.resolver().loadPomFromFile(pomStrategy.toPom(), pomStrategy.profiles()).resolve(groupId + ":" + artifactId).withoutTransitivity().asFile(); }
MavenResolverSystem maven = Maven.resolver(); PomEquippedResolveStage resolveStage = maven.loadPomFromFile("pom.xml"); MavenResolvedArtifact[] provided = resolveStage.importRuntimeDependencies().importDependencies(ScopeType.PROVIDED).resolve().using(new AcceptScopesStrategy(ScopeType.PROVIDED)).asResolvedArtifact(); for (MavenResolvedArtifact mra : provided) { MavenResolvedArtifact[] deps = resolveStage.importRuntimeAndTestDependencies().resolve().withTransitivity().asResolvedArtifact();
@Override public Archive<?> createAuxiliaryArchive() { final JavaArchive arquillianPactConsumer = ShrinkWrap.create(JavaArchive.class, "arquillian-pact-consumer.jar") // Add Core classes required in container part .addClasses(AbstractConsumerPactTest.class, RemoteConsumerPactTest.class, PactConsumerConfiguration.class, MockProviderConfigCreator.class, PactConsumerConfigurator.class, PactConsumerRemoteExtension.class, PactFilesCommand.class, ConsumerProviderPair.class, ResolveClassAnnotation.class) .addPackages(true, Pact.class.getPackage()) .addAsServiceProvider(RemoteLoadableExtension.class, PactConsumerRemoteExtension.class); final Properties properties = pactConsumerConfigurationInstance.get().asProperties(); String configuration = toString(properties); arquillianPactConsumer.add(new StringAsset(configuration), "/pact-consumer-configuration.properties"); final JavaArchive[] pactConsumerDeps = Maven.resolver() .resolve("au.com.dius:pact-jvm-consumer_2.11:" + getVersion()) .withTransitivity().as(JavaArchive.class); final JavaArchive merge = merge(arquillianPactConsumer, pactConsumerDeps); return merge; }
@Deployment public static WebArchive processArchive() { return initWebArchiveDeployment("test.war", "singleEngineWithProcessEnginePlugin.xml") .addClass(GroovyProcessEnginePlugin.class) .addAsResource("org/camunda/bpm/integrationtest/deployment/war/groovy.bpmn20.xml") .addAsResource("org/camunda/bpm/integrationtest/deployment/war/groovyAsync.bpmn20.xml") .addAsLibraries(Maven.resolver() .offline() .loadPomFromFile("pom.xml") .resolve("org.codehaus.groovy:groovy-all") .withoutTransitivity() .as(JavaArchive.class)); }
public static File[] resolveDependencies() { return Maven.resolver() .offline() .loadPomFromFile("pom.xml") .resolve( "org.infinispan:infinispan-core") .withTransitivity() .asFile(); } }
/** * Resolves Maven dependency and writes it to the cache, so it can be reused next run */ private void resolveMavenDependency(String missingDependency, File dir) { MavenResolverSystem resolver = getMavenResolver(); JavaArchive[] dependencies; if (missingDependency.matches("^[^:]+:[^:]+:[^:]+")) { // resolution of the artifact without a version specified dependencies = resolver.resolve(missingDependency).withClassPathResolution(false).withTransitivity() .as(JavaArchive.class); } else { // resolution of the artifact without a version specified dependencies = resolver.loadPomFromFile("pom.xml").resolve(missingDependency) .withClassPathResolution(false).withTransitivity().as(JavaArchive.class); } for (JavaArchive archive : dependencies) { dir.mkdirs(); if (mavenDependencyExcluded(archive.getName())) { continue; } final File outputFile = new File(dir, archive.getName()); archive.as(ZipExporter.class).exportTo(outputFile, true); } }
List<File> files = new ArrayList<File>(); MavenResolvedArtifact artifact = resolver.resolve( groupId + ":" + artifactId + ":" + version ).withoutTransitivity().asSingle(MavenResolvedArtifact.class); files.add(artifact.asFile()); for(MavenArtifactInfo dependency : dependencies) { File[] jars = resolver.resolve( dependency.getCoordinate().toCanonicalForm() ).withTransitivity().asFile(); for(File jar : jars) { files.add(jar);
@Override public File call() throws Exception { return Maven.resolver().resolve(distributableCoordinate.toCanonicalForm()) .withoutTransitivity() .asSingle(GenericArchive.class) .as(ExplodedExporter.class) .exportExploded(targetDirectory, "."); } });
public void unpackContainerConfigurationFiles(@Observes ConfigureContainer event) { Validate.notNull(configuration, "fundamental test configuration is not setup"); String configurationFiles = configuration.getContainerConfiguration(); if (configurationFiles == null || configurationFiles.isEmpty()) { return; } Validate.notNull(configuration.getContainerHome(), "container home must be set"); File containerHome = new File(configuration.getContainerHome()); InputStream artifactStream = Maven.resolver().resolve(configurationFiles).withClassPathResolution(false).withoutTransitivity().asSingleInputStream(); unzip(artifactStream, containerHome, true); log.info(String.format("The container configuration '%s' was unpacked into '%s'", configurationFiles, containerHome.getAbsolutePath())); }
/** * Returns the set of dependencies defined as org.hibernate:hibernate-search-orm at * the version being built. We use transitive dependencies to include the version * of hibernate-search-engine and Apache Lucene at the currently built version, but * then need to exclude the packages already provided by the application server such * as Hibernate ORM. * * @return the set of dependencies a user would need to bundle in a web app */ public static JavaArchive[] hibernateSearchLibraries() { return Maven.resolver() .resolve( "org.hibernate:hibernate-search-orm:" + getCurrentVersion() ) // we need some dependencies at the right version: Lucene, search-engine, etc.. .using( new RejectDependenciesStrategy( false, exclusions ) ) .as( JavaArchive.class ); }
/** * Obtains JavaArchive with phantomjs binary */ protected File getJavaArchive(String version) { String v = version; if (v == null) { v = ResolverConfiguration.get().version(); } final String gav = getArtifactCanonicalForm(v); return Maven.resolver().resolve(gav).withoutTransitivity().asSingleFile(); }
protected final WebArchive baseApplicationArchive(final String archiveName) { final File[] files = Maven. configureResolver(). fromClassloaderResource("settings.xml"). resolve(GROUP_ID+":"+ARTIFACT_ID+":"+PACKAGING+":"+VERSION). withoutTransitivity(). as(File.class); final WebArchive archive = ShrinkWrap. create(WebArchive.class,archiveName). merge(ShrinkWrap.createFromZipFile(WebArchive.class,files[0])); return archive; } }
protected static PomEquippedResolveStage getResolver(String pom) { return Maven.resolver().loadPomFromFile(pom); }
private static File resolveVersion(String warVersion) { try { return getResolver().resolve(warVersion).withoutTransitivity().asSingleFile(); } catch (NoResolvedResultException e) { LOG.warn("Could not find version", e); return null; } }
/** * @return the Maven coordinates of all archives returned by {@link #hibernateSearchLibraries()} */ private static String[] coordinatesOfHibernateSearchLibraries() { return Maven.resolver() .resolve( "org.hibernate:hibernate-search-orm:" + getCurrentVersion() ) .using( new RejectDependenciesStrategy( false, exclusions ) ) .asList( MavenResolvedArtifact.class ) .stream().map( m -> m.getCoordinate().getGroupId().toString() + ":" + m.getCoordinate().getArtifactId().toString() ) .toArray( String[]::new ); }
private static String getLatestVersion(String groupId, String artifactId, String minVersion, DeployableType type) { LOG.debug("Looking for version: {}/{}", groupId, artifactId); String searchVersion = String.format("(%s,)", minVersion); MavenVersionRangeResult versionRangeResult = getResolver().resolveVersionRange(formatMavenId(groupId, artifactId, searchVersion, type)); if (!versionRangeResult.getHighestVersion().getVersion().contains(SNAPSHOT)) { return versionRangeResult.getHighestVersion().getVersion(); } Map<Semver, MavenCoordinate> versionMap = new HashMap<>(); versionRangeResult.getVersions().stream().forEach(c -> { versionMap.put(new Semver(c.getVersion(), SemverType.LOOSE), c); }); Semver version = versionMap.keySet().stream() .filter(v -> !v.getOriginalValue().contains(SNAPSHOT)) .max(ORDER).get(); LOG.debug("Found version: {}/{} -> {}", groupId, artifactId, version); return versionMap.get(version).getVersion(); }
/** * Resolve an {@link Archive} from Maven coordinates. */ protected static File[] resolveDependencies(final String coords) { return Maven.resolver() .loadPomFromFile("pom.xml") .resolve(coords) .withTransitivity() .asFile(); }