org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinate Java Examples
The following examples show how to use
org.jboss.shrinkwrap.resolver.api.maven.coordinate.MavenCoordinate.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ShrinkwrapArtifactResolvingHelper.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 6 votes |
@Override public Set<ArtifactSpec> resolveAll(final Set<ArtifactSpec> specs) { if (specs.isEmpty()) { return specs; } resetListeners(); final MavenResolvedArtifact[] artifacts = withResolver(r -> r.resolve(specs.stream().map(ArtifactSpec::mavenGav).collect(Collectors.toList())) .withTransitivity() .as(MavenResolvedArtifact.class)); return Arrays.stream(artifacts).map(artifact -> { final MavenCoordinate coord = artifact.getCoordinate(); return new ArtifactSpec("compile", coord.getGroupId(), coord.getArtifactId(), coord.getVersion(), coord.getPackaging().getId(), coord.getClassifier(), artifact.asFile()); }).collect(Collectors.toSet()); }
Example #2
Source File: Jbang.java From jbang with MIT License | 5 votes |
static List<MavenCoordinate> findDeps(File pom) { // todo use to dump out pom dependencies return Maven.resolver() .loadPomFromFile(pom) .importCompileAndRuntimeDependencies() .resolve() .withoutTransitivity() .asList(MavenCoordinate.class); }
Example #3
Source File: EarGenericBuilder.java From arquillian-suite-extension with Apache License 2.0 | 5 votes |
/** * Check if artefact should be filtered (omitted from packaging). * <p> * By default all artefact witch groups start with org.jboss.(shrinkwrap|arqrquillian) are filtered. * </p> * @param artifactCoordinate Artifact coordinate to check * @return true if artifact should be filtered */ private static boolean isFiltered(MavenCoordinate artifactCoordinate) { if (artifactCoordinate.getGroupId().startsWith("org.jboss.shrinkwrap")) { return true; } if (artifactCoordinate.getGroupId().startsWith("org.jboss.arquillian")) { return true; } if (artifactCoordinate.getGroupId().startsWith("org.jboss.as")) { return true; } return false; }
Example #4
Source File: EarGenericBuilder.java From arquillian-suite-extension with Apache License 2.0 | 5 votes |
/** * Sprawdza czy dany artefakt jest ejb (ale nie jest ejb-clientem). Artefakt w formie MavenCoordinate. * * FIXME: Z powodu bledu shrinkwrapa szukamy tak na lewo po nazwie. * * @param artifactCoordinate MavenCoordinate artefaktu do sprawdzenia * @return true jesli jest projektem ejb */ private static boolean isArtifactEjb(MavenCoordinate artifactCoordinate) { if ("client".equals(artifactCoordinate.getClassifier())) { return false; } if (!artifactCoordinate.getGroupId().startsWith("pl.gov.coi")) { return false; } if (!artifactCoordinate.getArtifactId().toLowerCase().contains("ejb")) { return false; } return true; }
Example #5
Source File: DistributionController.java From arquillian-container-chameleon with Apache License 2.0 | 5 votes |
private File fetchFromMavenRepository(ExecutorService executor) { final MavenCoordinate distributableCoordinate = toMavenCoordinate(targetAdapter.distribution()); if (distributableCoordinate != null) { final File targetDirectory = new File(new File(distributionDownloadFolder, "server"), distributableCoordinate.getArtifactId() + "_" + distributableCoordinate.getVersion()); if (serverAlreadyDownloaded(targetDirectory)) { return getDistributionHome(targetDirectory); } System.out.println( "Arquillian Chameleon: downloading distribution " + distributableCoordinate.toCanonicalForm()); Future<File> uncompressDirectory = executor.submit(new Callable<File>() { @Override public File call() throws Exception { return Maven.resolver().resolve(distributableCoordinate.toCanonicalForm()) .withoutTransitivity() .asSingle(GenericArchive.class) .as(ExplodedExporter.class) .exportExploded(targetDirectory, "."); } }); try { while (!uncompressDirectory.isDone()) { System.out.print(PROGRESS_INDICATOR); Thread.sleep(HALF_A_SECOND); } System.out.println(); return getDistributionHome(uncompressDirectory.get()); } catch (Exception e) { throw new RuntimeException(e); } } return null; }
Example #6
Source File: ShrinkwrapArtifactResolvingHelper.java From thorntail with Apache License 2.0 | 5 votes |
public MavenDependency createMavenDependency(final ArtifactSpec spec) { final MavenCoordinate newCoordinate = MavenCoordinates.createCoordinate( spec.groupId(), spec.artifactId(), spec.version(), PackagingType.of(spec.type()), spec.classifier()); return MavenDependencies.createDependency(newCoordinate, ScopeType.fromScopeType(spec.scope), false); }
Example #7
Source File: DependencyResolverTest.java From jbang with MIT License | 5 votes |
@Test void testdepIdWithPlaceHoldersToArtifact() { dev.jbang.Detector detector = new dev.jbang.Detector(); detector.detect(new Properties(), Collections.emptyList()); String gav = PropertiesValueResolver.replaceProperties( "com.example:my-native-library:1.0.0:${os.detected.jfxname}"); MavenCoordinate artifact = new DependencyUtil().depIdToArtifact(gav); assertEquals("com.example", artifact.getGroupId()); assertEquals("my-native-library", artifact.getArtifactId()); assertEquals("1.0.0", artifact.getVersion()); assertEquals(System.getProperty("os.detected.jfxname"), artifact.getClassifier()); assertEquals("jar", artifact.getType().getExtension()); }
Example #8
Source File: DependencyResolverTest.java From jbang with MIT License | 5 votes |
@Test void testdepIdToArtifact() { DependencyUtil dr = new DependencyUtil(); MavenCoordinate artifact = dr.depIdToArtifact("com.offbytwo:docopt:0.6.0.20150202:redhat@doc"); assertEquals("com.offbytwo", artifact.getGroupId()); assertEquals("docopt", artifact.getArtifactId()); assertEquals("0.6.0.20150202", artifact.getVersion()); assertEquals("redhat", artifact.getClassifier()); assertEquals("doc", artifact.getType().getId()); artifact = dr.depIdToArtifact("com.offbytwo:docopt:0.6.0.20150202"); assertEquals("com.offbytwo", artifact.getGroupId()); assertEquals("docopt", artifact.getArtifactId()); assertEquals("0.6.0.20150202", artifact.getVersion()); assertEquals("", artifact.getClassifier()); assertEquals("jar", artifact.getType().getId()); artifact = dr.depIdToArtifact("com.offbytwo:docopt:0.6+"); assertEquals("com.offbytwo", artifact.getGroupId()); assertEquals("docopt", artifact.getArtifactId()); assertEquals("[0.6,)", artifact.getVersion()); assertEquals("", artifact.getClassifier()); assertEquals("jar", artifact.getType().getId()); assertThrows(IllegalStateException.class, () -> dr.depIdToArtifact("bla?f")); }
Example #9
Source File: DependencyUtil.java From jbang with MIT License | 5 votes |
public MavenCoordinate depIdToArtifact(String depId) { Pattern gavPattern = Pattern.compile( "^(?<groupid>[^:]*):(?<artifactid>[^:]*):(?<version>[^:@]*)(:(?<classifier>[^@]*))?(@(?<type>.*))?$"); Matcher gav = gavPattern.matcher(depId); gav.find(); if (!gav.matches()) { throw new IllegalStateException(String.format( "[ERROR] Invalid dependency locator: '%s'. Expected format is groupId:artifactId:version[:classifier][@type]", depId)); } String groupId = gav.group("groupid"); String artifactId = gav.group("artifactid"); String version = formatVersion(gav.group("version")); String classifier = gav.group("classifier"); String type = Optional.ofNullable(gav.group("type")).orElse("jar"); // String groupId, String artifactId, String classifier, String extension, // String version // String groupId, String artifactId, String version, String scope, String type, // String classifier, ArtifactHandler artifactHandler // shrinkwrap format: groupId:artifactId:[packagingType:[classifier]]:version return MavenCoordinates.createCoordinate(groupId, artifactId, version, PackagingType.of(type), classifier); }
Example #10
Source File: UberjarSimpleContainer.java From thorntail with Apache License 2.0 | 4 votes |
private String ga(final MavenCoordinate coord) { return String.format("%s:%s", coord.getGroupId(), coord.getArtifactId()); }
Example #11
Source File: UberjarSimpleContainer.java From thorntail with Apache License 2.0 | 4 votes |
private String gav(final MavenCoordinate coord) { return gav(coord.getGroupId(), coord.getArtifactId(), coord.getVersion()); }
Example #12
Source File: ShrinkwrapArtifactResolvingHelper.java From thorntail with Apache License 2.0 | 4 votes |
@Override public Set<ArtifactSpec> resolveAll(final Collection<ArtifactSpec> specs, boolean transitive, boolean defaultExcludes) { if (specs.isEmpty()) { return Collections.emptySet(); } final Set<ArtifactSpec> resolvedSpecs = new HashSet<>(); // If we don't need transitive dependencies, then perform a dependency resolution only for the artifacts that do not have // a file reference. if (!transitive) { specs.stream().filter(s -> s.file != null).forEach(resolvedSpecs::add); specs.removeAll(resolvedSpecs); if (specs.isEmpty()) { return resolvedSpecs; } } MavenResolutionStrategy transitivityStrategy = (transitive ? TransitiveStrategy.INSTANCE : NonTransitiveStrategy.INSTANCE); resetListeners(); final MavenResolvedArtifact[] artifacts = withResolver(r -> { specs.forEach(spec -> r.addDependency(createMavenDependency(spec))); return r.resolve() .using(transitivityStrategy) .as(MavenResolvedArtifact.class); }); resolvedSpecs.addAll( Arrays.stream(artifacts).map(artifact -> { final MavenCoordinate coord = artifact.getCoordinate(); return new ArtifactSpec(artifact.getScope().toString(), coord.getGroupId(), coord.getArtifactId(), coord.getVersion(), coord.getPackaging().getId(), coord.getClassifier(), artifact.asFile()); }).collect(Collectors.toSet()) ); return resolvedSpecs; }
Example #13
Source File: ProjectService.java From citrus-admin with Apache License 2.0 | 4 votes |
@PostConstruct public void loadDefaultProject() { String defaultProjectHome = System.getProperty(Application.PROJECT_HOME, System.getenv(Application.PROJECT_HOME_ENV)); if (project == null && StringUtils.hasText(defaultProjectHome)) { setActiveProject(load(defaultProjectHome)); } String repositoryUrl = System.getProperty(Application.PROJECT_REPOSITORY, System.getenv(Application.PROJECT_REPOSITORY_ENV)); if (project == null && StringUtils.hasText(repositoryUrl)) { Repository repository; String vcs = System.getProperty(Application.PROJECT_VERSION_CONTROL, Optional.ofNullable(System.getenv(Application.PROJECT_VERSION_CONTROL_ENV)).orElse(Repository.VERSION_CONTROL_GIT)); if (vcs.equalsIgnoreCase(Repository.VERSION_CONTROL_GIT)) { repository = new GitRepository(); } else if (vcs.equalsIgnoreCase(Repository.VERSION_CONTROL_SVN)) { repository = new SvnRepository(); } else { throw new ApplicationRuntimeException(String.format("Unsupported version control system '%s'", vcs)); } repository.setUrl(repositoryUrl); repository.setBranch(System.getProperty(Application.PROJECT_REPOSITORY_BRANCH, System.getenv(Application.PROJECT_REPOSITORY_BRANCH_ENV) != null ? System.getenv(Application.PROJECT_REPOSITORY_BRANCH_ENV) : repository.getBranch())); repository.setModule(System.getProperty(Application.PROJECT_REPOSITORY_MODULE, System.getenv(Application.PROJECT_REPOSITORY_MODULE_ENV) != null ? System.getenv(Application.PROJECT_REPOSITORY_MODULE_ENV) : repository.getModule())); repository.setUsername(System.getProperty(Application.PROJECT_REPOSITORY_USERNAME, System.getenv(Application.PROJECT_REPOSITORY_USERNAME_ENV))); repository.setPassword(System.getProperty(Application.PROJECT_REPOSITORY_PASSWORD, System.getenv(Application.PROJECT_REPOSITORY_PASSWORD_ENV))); create(repository); } String mavenArchetype = System.getProperty(Application.MAVEN_ARCHETYPE_COORDINATES, System.getenv(Application.MAVEN_ARCHETYPE_COORDINATES_ENV)); if (project == null && StringUtils.hasText(mavenArchetype)) { MavenArchetype archetype = new MavenArchetype(); MavenCoordinate archetypeCoordinates = MavenCoordinates.createCoordinate(mavenArchetype); archetype.setArchetypeGroupId(archetypeCoordinates.getGroupId()); archetype.setArchetypeArtifactId(archetypeCoordinates.getArtifactId()); archetype.setArchetypeVersion(archetypeCoordinates.getVersion()); String mavenProject = System.getProperty(Application.MAVEN_PROJECT_COORDINATES, System.getenv(Application.MAVEN_PROJECT_COORDINATES_ENV) != null ? System.getenv(Application.MAVEN_PROJECT_COORDINATES_ENV) : "com.consol.citrus:citrus-project:1.0.0"); MavenCoordinate projectCoordinates = MavenCoordinates.createCoordinate(mavenProject); archetype.setGroupId(projectCoordinates.getGroupId()); archetype.setArtifactId(projectCoordinates.getArtifactId()); archetype.setVersion(projectCoordinates.getVersion()); archetype.setPackageName(System.getProperty(Application.MAVEN_PROJECT_PACKAGE, System.getenv(Application.MAVEN_PROJECT_PACKAGE_ENV) != null ? System.getenv(Application.MAVEN_PROJECT_PACKAGE_ENV) : projectCoordinates.getGroupId())); create(archetype); } }
Example #14
Source File: UberjarSimpleContainer.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 4 votes |
private String ga(final MavenCoordinate coord) { return String.format("%s:%s", coord.getGroupId(), coord.getArtifactId()); }
Example #15
Source File: UberjarSimpleContainer.java From ARCHIVE-wildfly-swarm with Apache License 2.0 | 4 votes |
private String gav(final MavenCoordinate coord) { return gav(coord.getGroupId(), coord.getArtifactId(), coord.getVersion()); }
Example #16
Source File: Utils.java From arquillian-container-chameleon with Apache License 2.0 | 4 votes |
public static MavenCoordinate toMavenCoordinate(String dep) { return MavenCoordinates.createCoordinate(dep); }
Example #17
Source File: TestAddDeps.java From jbang with MIT License | 3 votes |
@Test void testAddDeps(@TempDir File dir) throws IOException { File pom = new File(dir, "pom.xml"); Util.writeString(pom.toPath(), example); List<MavenCoordinate> result = Jbang.findDeps(pom); assertThat(result.stream().map(MavenCoordinate::toCanonicalForm).collect(Collectors.toList()), containsInAnyOrder("org.projectlombok:lombok:jar:1.18.10", "info.picocli:picocli:jar:4.1.4")); }