/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.resolver.api.Coordinate#toCanonicalForm() */ @Override public String toCanonicalForm() { return delegate.toCanonicalForm() + ':' + this.getScope().toString(); }
ScopeType[] scopes = ScopeType.values(); if (scope != null && !"".equals(scope)) { scopes = new ScopeType[] { ScopeType.fromScopeType(scope) };
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); }
new AddScopedDependenciesTask(ScopeType.values()).execute(session); final MavenResolutionStrategy scopeStrategy = new AcceptScopesStrategy(scopes); final Collection<MavenResolvedArtifact> artifactResults = session.resolveDependencies(scopeStrategy);
if (!dep.getScope().equals(ScopeType.TEST)) { long before = System.currentTimeMillis(); FlexyClassLoader depCl = get(key); if (dep.getScope().equals(ScopeType.RUNTIME)) { try { parentCl.load(depJar); if (!dep.getScope().equals(ScopeType.RUNTIME)) { parentCl.attachChild(depCl); Log.debug("{} = {} already loaded", indent, key, (System.currentTimeMillis() - before));
tool.dependency(dep.getScope().name(), coord.getGroupId(), coord.getArtifactId(), coord.getVersion(), coord.getPackaging().getExtension(), coord.getClassifier(), dep.asFile(), tool.dependency(dep.getScope().name(), coord.getGroupId(), coord.getArtifactId(), coord.getVersion(), coord.getPackaging().getExtension(), coord.getClassifier(), dep.asFile(),
scope = ScopeType.fromScopeType(resolvedScope); } catch (IllegalArgumentException e) {
new AddScopedDependenciesTask(ScopeType.values()).execute(session); final MavenResolutionStrategy scopeStrategy = new AcceptScopesStrategy(scopes); final Collection<MavenResolvedArtifact> artifactResults = session.resolveDependencies(scopeStrategy);
/** * {@inheritDoc} * * @see org.jboss.shrinkwrap.resolver.api.Coordinate#toCanonicalForm() */ @Override public String toCanonicalForm() { return delegate.toCanonicalForm() + ':' + this.getScope().toString(); }
scope = ScopeType.fromScopeType(resolvedScope); } catch (IllegalArgumentException e) {
Arrays.stream(artifacts).map(artifact -> { final MavenCoordinate coord = artifact.getCoordinate(); return new ArtifactSpec(artifact.getScope().toString(), coord.getGroupId(), coord.getArtifactId(),
public static MavenDependency fromDependency(final Dependency dependency) { final Artifact artifact = dependency.getArtifact(); final PackagingType packaging = PackagingType .of(artifact.getProperty(ArtifactProperties.TYPE, artifact.getExtension())); final String classifier = artifact.getClassifier().length() == 0 ? packaging.getClassifier() : artifact.getClassifier(); final MavenCoordinate coordinate = MavenCoordinates.createCoordinate(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), packaging, classifier); // SHRINKRES-143 lets ignore invalid scope ScopeType scope = ScopeType.RUNTIME; try { scope = ScopeType.fromScopeType(dependency.getScope()); } catch (IllegalArgumentException e) { // let scope be RUNTIME log.log(Level.WARNING, "Invalid scope {0} of dependency {1} will be replaced by <scope>runtime</scope>", new Object[] { dependency.getScope(), coordinate.toCanonicalForm() }); } final MavenDependency result = MavenDependencies.createDependency(coordinate, scope, dependency.isOptional(), fromExclusions(dependency.getExclusions()).toArray(TYPESAFE_EXCLUSIONS_ARRAY)); return result; }
@Test public void test() { Assert.assertEquals("test", ScopeType.TEST.toString()); }
public static MavenDependency fromDependency(final Dependency dependency) { final Artifact artifact = dependency.getArtifact(); final PackagingType packaging = PackagingType .of(artifact.getProperty(ArtifactProperties.TYPE, artifact.getExtension())); final String classifier = artifact.getClassifier().length() == 0 ? packaging.getClassifier() : artifact.getClassifier(); final MavenCoordinate coordinate = MavenCoordinates.createCoordinate(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), packaging, classifier); // SHRINKRES-143 lets ignore invalid scope ScopeType scope = ScopeType.RUNTIME; try { scope = ScopeType.fromScopeType(dependency.getScope()); } catch (IllegalArgumentException e) { // let scope be RUNTIME log.log(Level.WARNING, "Invalid scope {0} of dependency {1} will be replaced by <scope>runtime</scope>", new Object[] { dependency.getScope(), coordinate.toCanonicalForm() }); } final MavenDependency result = MavenDependencies.createDependency(coordinate, scope, dependency.isOptional(), fromExclusions(dependency.getExclusions()).toArray(TYPESAFE_EXCLUSIONS_ARRAY)); return result; }
@Test public void provided() { Assert.assertEquals("provided", ScopeType.PROVIDED.toString()); }
/** * Creates MavenArtifactInfo based on DependencyNode. * * @param dependencyNode * dependencyNode * @return The new {@link MavenArtifactInfo> instance. */ static MavenArtifactInfo fromDependencyNode(final DependencyNode dependencyNode) { final Artifact artifact = dependencyNode.getDependency().getArtifact(); final List<DependencyNode> children = dependencyNode.getChildren(); // SHRINKRES-143 lets ignore invalid scope ScopeType scopeType = ScopeType.RUNTIME; try { scopeType = ScopeType.fromScopeType(dependencyNode.getDependency().getScope()); } catch (IllegalArgumentException e) { // let scope be RUNTIME log.log(Level.WARNING, "Invalid scope {0} of retrieved dependency {1} will be replaced by <scope>runtime</scope>", new Object[] { dependencyNode.getDependency().getScope(), dependencyNode.getDependency().getArtifact() }); } final boolean optional = dependencyNode.getDependency().isOptional(); return new MavenArtifactInfoImpl(artifact, scopeType, children, optional); }
@Test public void system() { Assert.assertEquals("system", ScopeType.SYSTEM.toString()); }
/** * Creates MavenArtifactInfo based on DependencyNode. * * @param dependencyNode * dependencyNode * @return The new {@link MavenArtifactInfo> instance. */ static MavenArtifactInfo fromDependencyNode(final DependencyNode dependencyNode) { final Artifact artifact = dependencyNode.getDependency().getArtifact(); final List<DependencyNode> children = dependencyNode.getChildren(); // SHRINKRES-143 lets ignore invalid scope ScopeType scopeType = ScopeType.RUNTIME; try { scopeType = ScopeType.fromScopeType(dependencyNode.getDependency().getScope()); } catch (IllegalArgumentException e) { // let scope be RUNTIME log.log(Level.WARNING, "Invalid scope {0} of retrieved dependency {1} will be replaced by <scope>runtime</scope>", new Object[] { dependencyNode.getDependency().getScope(), dependencyNode.getDependency().getArtifact() }); } final boolean optional = dependencyNode.getDependency().isOptional(); return new MavenArtifactInfoImpl(artifact, scopeType, children, optional); }
@Test public void importTest() { Assert.assertEquals("import", ScopeType.IMPORT.toString()); }
/** * Creates MavenResolvedArtifact based on ArtifactResult. * * @param artifactResult * @return */ static MavenResolvedArtifact fromArtifactResult(final ArtifactResult artifactResult) { final Artifact artifact = artifactResult.getArtifact(); final DependencyNode root = artifactResult.getRequest().getDependencyNode(); // SHRINKRES-143 lets ignore invalid scope ScopeType scopeType = ScopeType.RUNTIME; try { scopeType = ScopeType.fromScopeType(root.getDependency().getScope()); } catch (IllegalArgumentException e) { // let scope be RUNTIME log.log(Level.WARNING, "Invalid scope {0} of retrieved dependency {1} will be replaced by <scope>runtime</scope>", new Object[] { root.getDependency().getScope(), root.getDependency().getArtifact() }); } final List<DependencyNode> children = root.getChildren(); final boolean optional = root.getDependency().isOptional(); return new MavenResolvedArtifactImpl(artifact, scopeType, children, optional); }