public String getDirectory() { if ( directory == null ) { directory = getPackaging() + "s"; } return directory; }
public static ArtifactType newArtifactType( String id, ArtifactHandler handler ) { return new DefaultArtifactType( id, handler.getExtension(), handler.getClassifier(), handler.getLanguage(), handler.isAddedToClasspath(), handler.isIncludesDependencies() ); }
public ArtifactHandler getArtifactHandler( String type ) { ArtifactHandler handler = unmanagedHandlers.get( type ); if ( handler == null ) { handler = artifactHandlers.get( type ); if ( handler == null ) { handler = new DefaultArtifactHandler( type ); } } return handler; }
public String pathOf( Artifact artifact ) { ArtifactHandler artifactHandler = artifact.getArtifactHandler(); StringBuilder path = new StringBuilder( 128 ); path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() ); if ( artifact.hasClassifier() ) { path.append( ARTIFACT_SEPARATOR ).append( artifact.getClassifier() ); } if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 ) { path.append( GROUP_SEPARATOR ).append( artifactHandler.getExtension() ); } return path.toString(); }
@Deprecated public List<Artifact> getTestArtifacts() { List<Artifact> list = new ArrayList<>( getArtifacts().size() ); for ( Artifact a : getArtifacts() ) { // TODO classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() ) { list.add( a ); } } return list; }
public static ArtifactHandler newHandler( Artifact artifact ) { String type = artifact.getProperty( ArtifactProperties.TYPE, artifact.getExtension() ); DefaultArtifactHandler handler = new DefaultArtifactHandler( type ); handler.setExtension( artifact.getExtension() ); handler.setLanguage( artifact.getProperty( ArtifactProperties.LANGUAGE, null ) ); String addedToClasspath = artifact.getProperty( ArtifactProperties.CONSTITUTES_BUILD_PATH, "" ); handler.setAddedToClasspath( Boolean.parseBoolean( addedToClasspath ) ); String includesDependencies = artifact.getProperty( ArtifactProperties.INCLUDES_DEPENDENCIES, "" ); handler.setIncludesDependencies( Boolean.parseBoolean( includesDependencies ) ); return handler; }
@SuppressWarnings( "checkstyle:parameternumber" ) public DefaultArtifact( String groupId, String artifactId, VersionRange versionRange, String scope, String type, String classifier, ArtifactHandler artifactHandler, boolean optional ) { this.groupId = groupId; this.artifactId = artifactId; this.versionRange = versionRange; selectVersionFromNewRangeIfAvailable(); this.artifactHandler = artifactHandler; this.scope = scope; this.type = type; if ( classifier == null ) { classifier = artifactHandler.getClassifier(); } this.classifier = classifier; this.optional = optional; validateIdentity(); }
/** @deprecated we want to use the artifact method only, and ensure artifact.file is set correctly. */ @Deprecated public void install( String basedir, String finalName, Artifact artifact, ArtifactRepository localRepository ) throws ArtifactInstallationException { String extension = artifact.getArtifactHandler().getExtension(); File source = new File( basedir, finalName + "." + extension ); install( source, artifact, localRepository ); }
public List getTestArtifacts() { List list = new ArrayList( getArtifacts().size() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO: let the scope handler deal with this // NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform // this check... // if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) || // Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) // { // list.add( a ); // } list.add( a ); } } return list; }
private Artifact getArtifactFromPomProperties(String type, Properties pomProps) { return new DefaultArtifact( pomProps.getProperty("groupId"), pomProps.getProperty("artifactId"), pomProps.getProperty("version"), "runtime", type, pomProps.getProperty("classifier", ""), new DefaultArtifactHandler(type) ); }
@SuppressWarnings( "checkstyle:parameternumber" ) public DefaultArtifact( String groupId, String artifactId, VersionRange versionRange, String scope, String type, String classifier, ArtifactHandler artifactHandler, boolean optional ) { this.groupId = groupId; this.artifactId = artifactId; this.versionRange = versionRange; selectVersionFromNewRangeIfAvailable(); this.artifactHandler = artifactHandler; this.scope = scope; this.type = type; if ( classifier == null ) { classifier = artifactHandler.getClassifier(); } this.classifier = classifier; this.optional = optional; validateIdentity(); }
/** * Gets the repository conflict id of the specified artifact. Unlike the dependency conflict id, the repository * conflict id uses the artifact file extension instead of the artifact type. Hence, the repository conflict id more * closely reflects the identity of artifacts as perceived by a repository. * * @param artifact The artifact, must not be <code>null</code>. * @return The repository conflict id, never <code>null</code>. */ private String getRepositoryConflictId( Artifact artifact ) { StringBuffer buffer = new StringBuffer( 128 ); buffer.append( artifact.getGroupId() ); buffer.append( ':' ).append( artifact.getArtifactId() ); if ( artifact.getArtifactHandler() != null ) { buffer.append( ':' ).append( artifact.getArtifactHandler().getExtension() ); } else { buffer.append( ':' ).append( artifact.getType() ); } if ( artifact.hasClassifier() ) { buffer.append( ':' ).append( artifact.getClassifier() ); } return buffer.toString(); }
public List getSystemArtifacts() { List list = new ArrayList( getArtifacts().size() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO: let the scope handler deal with this if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { list.add( a ); } } } return list; }
/** * @deprecated we want to use the artifact method only, and ensure artifact.file is set * correctly. */ @Deprecated public void deploy( String basedir, String finalName, Artifact artifact, ArtifactRepository deploymentRepository, ArtifactRepository localRepository ) throws ArtifactDeploymentException { String extension = artifact.getArtifactHandler().getExtension(); File source = new File( basedir, finalName + "." + extension ); deploy( source, artifact, deploymentRepository, localRepository ); }
@Deprecated public List<Artifact> getSystemArtifacts() { List<Artifact> list = new ArrayList<>( getArtifacts().size() ); for ( Artifact a : getArtifacts() ) { // TODO classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO let the scope handler deal with this if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { list.add( a ); } } } return list; }
public String pathOf( Artifact artifact ) { ArtifactHandler artifactHandler = artifact.getArtifactHandler(); StringBuilder path = new StringBuilder( 128 ); path.append( formatAsDirectory( artifact.getGroupId() ) ).append( PATH_SEPARATOR ); path.append( artifact.getArtifactId() ).append( PATH_SEPARATOR ); path.append( artifact.getBaseVersion() ).append( PATH_SEPARATOR ); path.append( artifact.getArtifactId() ).append( ARTIFACT_SEPARATOR ).append( artifact.getVersion() ); if ( artifact.hasClassifier() ) { path.append( ARTIFACT_SEPARATOR ).append( artifact.getClassifier() ); } if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 ) { path.append( GROUP_SEPARATOR ).append( artifactHandler.getExtension() ); } return path.toString(); }
public List getRuntimeArtifacts() { List list = new ArrayList( getArtifacts().size() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO: let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) { list.add( a ); } } } return list; }
@Deprecated public List<Artifact> getRuntimeArtifacts() { List<Artifact> list = new ArrayList<>( getArtifacts().size() ); for ( Artifact a : getArtifacts() ) { // TODO classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() // TODO let the scope handler deal with this && ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) ) ) { list.add( a ); } } return list; }
public List<String> getTestClasspathElements() throws DependencyResolutionRequiredException { List<String> list = new ArrayList<>( getArtifacts().size() + 2 ); String d = getBuild().getTestOutputDirectory(); if ( d != null ) { list.add( d ); } d = getBuild().getOutputDirectory(); if ( d != null ) { list.add( d ); } for ( Artifact a : getArtifacts() ) { if ( a.getArtifactHandler().isAddedToClasspath() ) { addArtifactPath( a, list ); } } return list; }
public List getCompileArtifacts() { List list = new ArrayList( getArtifacts().size() ); for ( Iterator i = getArtifacts().iterator(); i.hasNext(); ) { Artifact a = (Artifact) i.next(); // TODO: classpath check doesn't belong here - that's the other method if ( a.getArtifactHandler().isAddedToClasspath() ) { // TODO: let the scope handler deal with this if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) || Artifact.SCOPE_SYSTEM.equals( a.getScope() ) ) { list.add( a ); } } } return list; }