mirror of https://github.com/apache/maven.git
add new methods to type handler:
- isAddedToClassPath (default false) - language (default "none") git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@320986 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c74d08fa48
commit
ed22c950e8
|
@ -33,4 +33,8 @@ public interface ArtifactHandler
|
||||||
String getPackaging();
|
String getPackaging();
|
||||||
|
|
||||||
boolean isIncludesDependencies();
|
boolean isIncludesDependencies();
|
||||||
|
|
||||||
|
String getLanguage();
|
||||||
|
|
||||||
|
boolean isAddedToClasspath();
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,10 @@ public class DefaultArtifactHandler
|
||||||
|
|
||||||
private boolean includesDependencies;
|
private boolean includesDependencies;
|
||||||
|
|
||||||
|
private String language;
|
||||||
|
|
||||||
|
private boolean addedToClasspath;
|
||||||
|
|
||||||
public DefaultArtifactHandler()
|
public DefaultArtifactHandler()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -85,4 +89,19 @@ public class DefaultArtifactHandler
|
||||||
{
|
{
|
||||||
return includesDependencies;
|
return includesDependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLanguage()
|
||||||
|
{
|
||||||
|
if ( language == null )
|
||||||
|
{
|
||||||
|
language = "none";
|
||||||
|
}
|
||||||
|
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAddedToClasspath()
|
||||||
|
{
|
||||||
|
return addedToClasspath;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,8 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<type>ejb</type>
|
<type>ejb</type>
|
||||||
<extension>jar</extension>
|
<extension>jar</extension>
|
||||||
|
<language>java</language>
|
||||||
|
<addedToClasspath>true</addedToClasspath>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
@ -44,6 +46,8 @@
|
||||||
<implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
|
<implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
|
||||||
<configuration>
|
<configuration>
|
||||||
<type>jar</type>
|
<type>jar</type>
|
||||||
|
<language>java</language>
|
||||||
|
<addedToClasspath>true</addedToClasspath>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
@ -56,6 +60,8 @@
|
||||||
<extension>jar</extension>
|
<extension>jar</extension>
|
||||||
<type>test-jar</type>
|
<type>test-jar</type>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
<language>java</language>
|
||||||
|
<addedToClasspath>true</addedToClasspath>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
@ -66,6 +72,8 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<type>maven-plugin</type>
|
<type>maven-plugin</type>
|
||||||
<extension>jar</extension>
|
<extension>jar</extension>
|
||||||
|
<language>java</language>
|
||||||
|
<addedToClasspath>true</addedToClasspath>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
@ -85,6 +93,20 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<type>java-source</type>
|
<type>java-source</type>
|
||||||
<extension>jar</extension>
|
<extension>jar</extension>
|
||||||
|
<language>java</language>
|
||||||
|
<addedToClasspath>false</addedToClasspath>
|
||||||
|
</configuration>
|
||||||
|
</component>
|
||||||
|
|
||||||
|
<component>
|
||||||
|
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
|
||||||
|
<role-hint>javadoc</role-hint>
|
||||||
|
<implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
|
||||||
|
<configuration>
|
||||||
|
<type>javadoc</type>
|
||||||
|
<extension>jar</extension>
|
||||||
|
<language>java</language>
|
||||||
|
<addedToClasspath>true</addedToClasspath>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
@ -95,6 +117,8 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<type>war</type>
|
<type>war</type>
|
||||||
<includesDependencies>true</includesDependencies>
|
<includesDependencies>true</includesDependencies>
|
||||||
|
<language>java</language>
|
||||||
|
<addedToClasspath>false</addedToClasspath>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
@ -105,6 +129,8 @@
|
||||||
<configuration>
|
<configuration>
|
||||||
<type>ear</type>
|
<type>ear</type>
|
||||||
<includesDependencies>true</includesDependencies>
|
<includesDependencies>true</includesDependencies>
|
||||||
|
<language>java</language>
|
||||||
|
<addedToClasspath>false</addedToClasspath>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
@ -117,6 +143,8 @@
|
||||||
<extension>jar</extension>
|
<extension>jar</extension>
|
||||||
<packaging>ejb</packaging>
|
<packaging>ejb</packaging>
|
||||||
<classifier>client</classifier>
|
<classifier>client</classifier>
|
||||||
|
<language>java</language>
|
||||||
|
<addedToClasspath>true</addedToClasspath>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
||||||
|
|
||||||
|
|
|
@ -42,13 +42,13 @@ public class JarSourceMojo
|
||||||
* @deprecated ICK! This needs to be generalized OUTSIDE of this mojo!
|
* @deprecated ICK! This needs to be generalized OUTSIDE of this mojo!
|
||||||
*/
|
*/
|
||||||
private static final List BANNED_PACKAGINGS;
|
private static final List BANNED_PACKAGINGS;
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
List banned = new ArrayList();
|
List banned = new ArrayList();
|
||||||
|
|
||||||
banned.add( "pom" );
|
banned.add( "pom" );
|
||||||
|
|
||||||
BANNED_PACKAGINGS = banned;
|
BANNED_PACKAGINGS = banned;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public class JarSourceMojo
|
||||||
* @parameter expression="${component.org.apache.maven.project.MavenProjectHelper}
|
* @parameter expression="${component.org.apache.maven.project.MavenProjectHelper}
|
||||||
*/
|
*/
|
||||||
private MavenProjectHelper projectHelper;
|
private MavenProjectHelper projectHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @parameter expression="${project.packaging}"
|
* @parameter expression="${project.packaging}"
|
||||||
* @readonly
|
* @readonly
|
||||||
|
@ -76,7 +76,7 @@ public class JarSourceMojo
|
||||||
* @required
|
* @required
|
||||||
*/
|
*/
|
||||||
private String finalName;
|
private String finalName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @parameter expression="${attach}" default-value="true"
|
* @parameter expression="${attach}" default-value="true"
|
||||||
*/
|
*/
|
||||||
|
@ -93,23 +93,17 @@ public class JarSourceMojo
|
||||||
* @required
|
* @required
|
||||||
*/
|
*/
|
||||||
private File outputDirectory;
|
private File outputDirectory;
|
||||||
|
|
||||||
public void execute()
|
public void execute()
|
||||||
throws MojoExecutionException
|
throws MojoExecutionException
|
||||||
{
|
{
|
||||||
if ( !attach )
|
if ( BANNED_PACKAGINGS.contains( packaging ) )
|
||||||
{
|
|
||||||
getLog().info( "NOT adding java-sources to attached artifacts list." );
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if ( BANNED_PACKAGINGS.contains( packaging ) )
|
|
||||||
{
|
{
|
||||||
getLog().info( "NOT adding java-sources to attached artifacts for packaging: \'" + packaging + "\'." );
|
getLog().info( "NOT adding java-sources to attached artifacts for packaging: \'" + packaging + "\'." );
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use a component lookup?
|
// TODO: use a component lookup?
|
||||||
JarArchiver archiver = new JarArchiver();
|
JarArchiver archiver = new JarArchiver();
|
||||||
|
|
||||||
|
@ -133,8 +127,16 @@ public class JarSourceMojo
|
||||||
throw new MojoExecutionException( "Error building source JAR", e );
|
throw new MojoExecutionException( "Error building source JAR", e );
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: these introduced dependencies on the project are going to become problematic - can we export it
|
if ( !attach )
|
||||||
// through metadata instead?
|
{
|
||||||
projectHelper.attachArtifact( project, "java-source", "sources", outputFile );
|
getLog().info( "NOT adding java-sources to attached artifacts list." );
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO: these introduced dependencies on the project are going to become problematic - can we export it
|
||||||
|
// through metadata instead?
|
||||||
|
projectHelper.attachArtifact( project, "java-source", "sources", outputFile );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -348,7 +348,7 @@ public class MavenProject
|
||||||
{
|
{
|
||||||
Artifact a = (Artifact) i.next();
|
Artifact a = (Artifact) i.next();
|
||||||
|
|
||||||
if ( isAddedToClasspath( a ) )
|
if ( a.getArtifactHandler().isAddedToClasspath() )
|
||||||
{
|
{
|
||||||
// TODO: let the scope handler deal with this
|
// TODO: let the scope handler deal with this
|
||||||
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) ||
|
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) ||
|
||||||
|
@ -384,7 +384,7 @@ public class MavenProject
|
||||||
Artifact a = (Artifact) i.next();
|
Artifact a = (Artifact) i.next();
|
||||||
|
|
||||||
// TODO: classpath check doesn't belong here - that's the other method
|
// TODO: classpath check doesn't belong here - that's the other method
|
||||||
if ( isAddedToClasspath( a ) )
|
if ( a.getArtifactHandler().isAddedToClasspath() )
|
||||||
{
|
{
|
||||||
// TODO: let the scope handler deal with this
|
// TODO: let the scope handler deal with this
|
||||||
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) ||
|
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_PROVIDED.equals( a.getScope() ) ||
|
||||||
|
@ -442,7 +442,7 @@ public class MavenProject
|
||||||
{
|
{
|
||||||
Artifact a = (Artifact) i.next();
|
Artifact a = (Artifact) i.next();
|
||||||
|
|
||||||
if ( isAddedToClasspath( a ) )
|
if ( a.getArtifactHandler().isAddedToClasspath() )
|
||||||
{
|
{
|
||||||
// TODO: let the scope handler deal with this
|
// 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
|
// NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform
|
||||||
|
@ -471,7 +471,7 @@ public class MavenProject
|
||||||
Artifact a = (Artifact) i.next();
|
Artifact a = (Artifact) i.next();
|
||||||
|
|
||||||
// TODO: classpath check doesn't belong here - that's the other method
|
// TODO: classpath check doesn't belong here - that's the other method
|
||||||
if ( isAddedToClasspath( a ) )
|
if ( a.getArtifactHandler().isAddedToClasspath() )
|
||||||
{
|
{
|
||||||
// TODO: let the scope handler deal with this
|
// 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
|
// NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform
|
||||||
|
@ -536,7 +536,7 @@ public class MavenProject
|
||||||
{
|
{
|
||||||
Artifact a = (Artifact) i.next();
|
Artifact a = (Artifact) i.next();
|
||||||
|
|
||||||
if ( isAddedToClasspath( a ) )
|
if ( a.getArtifactHandler().isAddedToClasspath() )
|
||||||
{
|
{
|
||||||
// TODO: let the scope handler deal with this
|
// TODO: let the scope handler deal with this
|
||||||
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
|
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
|
||||||
|
@ -562,7 +562,7 @@ public class MavenProject
|
||||||
Artifact a = (Artifact) i.next();
|
Artifact a = (Artifact) i.next();
|
||||||
|
|
||||||
// TODO: classpath check doesn't belong here - that's the other method
|
// TODO: classpath check doesn't belong here - that's the other method
|
||||||
if ( isAddedToClasspath( a ) )
|
if ( a.getArtifactHandler().isAddedToClasspath() )
|
||||||
{
|
{
|
||||||
// TODO: let the scope handler deal with this
|
// TODO: let the scope handler deal with this
|
||||||
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
|
if ( Artifact.SCOPE_COMPILE.equals( a.getScope() ) || Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
|
||||||
|
@ -618,7 +618,7 @@ public class MavenProject
|
||||||
{
|
{
|
||||||
Artifact a = (Artifact) i.next();
|
Artifact a = (Artifact) i.next();
|
||||||
|
|
||||||
if ( isAddedToClasspath( a ) )
|
if ( a.getArtifactHandler().isAddedToClasspath() )
|
||||||
{
|
{
|
||||||
// TODO: let the scope handler deal with this
|
// TODO: let the scope handler deal with this
|
||||||
if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
|
if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
|
||||||
|
@ -653,7 +653,7 @@ public class MavenProject
|
||||||
Artifact a = (Artifact) i.next();
|
Artifact a = (Artifact) i.next();
|
||||||
|
|
||||||
// TODO: classpath check doesn't belong here - that's the other method
|
// TODO: classpath check doesn't belong here - that's the other method
|
||||||
if ( isAddedToClasspath( a ) )
|
if ( a.getArtifactHandler().isAddedToClasspath() )
|
||||||
{
|
{
|
||||||
// TODO: let the scope handler deal with this
|
// TODO: let the scope handler deal with this
|
||||||
if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
|
if ( Artifact.SCOPE_SYSTEM.equals( a.getScope() ) )
|
||||||
|
@ -698,14 +698,6 @@ public class MavenProject
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isAddedToClasspath( Artifact artifact )
|
|
||||||
{
|
|
||||||
String type = artifact.getType();
|
|
||||||
|
|
||||||
// TODO: utilise type handler
|
|
||||||
return "jar".equals( type ) || "ejb".equals( type ) || "ejb-client".equals( type ) || "test-jar".equals( type );
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
// Delegate to the model
|
// Delegate to the model
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue