Package org.apache.maven.plugins.source
Class AbstractSourceJarMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.apache.maven.plugins.source.AbstractSourceJarMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
- Direct Known Subclasses:
SourceJarNoForkMojo
,TestSourceJarNoForkMojo
public abstract class AbstractSourceJarMojo extends org.apache.maven.plugin.AbstractMojo
Base class for bundling sources into a jar archive.- Since:
- 2.0.3
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
excludeResources
Specifies whether or not to exclude resources from the sources-jar.protected String
finalName
The filename to be used for the generated archive file.protected boolean
includePom
Specifies whether or not to include the POM file in the sources-jar.protected File
outputDirectory
The directory where the generated archive file will be put.protected List<org.apache.maven.project.MavenProject>
reactorProjects
Contains the full list of projects in the reactor.
-
Constructor Summary
Constructors Constructor Description AbstractSourceJarMojo()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addDirectory(org.codehaus.plexus.archiver.Archiver archiver, File sourceDirectory, String[] pIncludes, String[] pExcludes)
protected void
addDirectory(org.codehaus.plexus.archiver.Archiver archiver, File sourceDirectory, String prefix, String[] pIncludes, String[] pExcludes)
protected void
archiveProjectContent(org.apache.maven.project.MavenProject p, org.codehaus.plexus.archiver.Archiver archiver)
protected org.apache.maven.archiver.MavenArchiver
createArchiver()
void
execute()
protected abstract String
getClassifier()
protected String
getExtension()
protected org.apache.maven.project.MavenProject
getProject()
protected org.apache.maven.project.MavenProject
getProject(org.apache.maven.project.MavenProject p)
protected abstract List<org.apache.maven.model.Resource>
getResources(org.apache.maven.project.MavenProject p)
protected abstract List<String>
getSources(org.apache.maven.project.MavenProject p)
protected String
getType()
protected void
packageSources(List<org.apache.maven.project.MavenProject> theProjects)
protected void
packageSources(org.apache.maven.project.MavenProject p)
protected void
setProject(org.apache.maven.project.MavenProject project)
-
-
-
Field Detail
-
excludeResources
@Parameter(property="maven.source.excludeResources", defaultValue="false") protected boolean excludeResources
Specifies whether or not to exclude resources from the sources-jar. This can be convenient if your project includes large resources, such as images, and you don't want to include them in the sources-jar.- Since:
- 2.0.4
-
includePom
@Parameter(property="maven.source.includePom", defaultValue="false") protected boolean includePom
Specifies whether or not to include the POM file in the sources-jar.- Since:
- 2.1
-
outputDirectory
@Parameter(defaultValue="${project.build.directory}") protected File outputDirectory
The directory where the generated archive file will be put.
-
finalName
@Parameter(defaultValue="${project.build.finalName}") protected String finalName
The filename to be used for the generated archive file. For the source:jar goal, "-sources" is appended to this filename. For the source:test-jar goal, "-test-sources" is appended.
-
reactorProjects
@Parameter(defaultValue="${reactorProjects}", readonly=true) protected List<org.apache.maven.project.MavenProject> reactorProjects
Contains the full list of projects in the reactor.
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getClassifier
protected abstract String getClassifier()
- Returns:
- the wanted classifier, ie
sources
ortest-sources
-
getSources
protected abstract List<String> getSources(org.apache.maven.project.MavenProject p) throws org.apache.maven.plugin.MojoExecutionException
- Parameters:
p
-MavenProject
not null- Returns:
- the compile or test sources
- Throws:
org.apache.maven.plugin.MojoExecutionException
- in case of an error.
-
getResources
protected abstract List<org.apache.maven.model.Resource> getResources(org.apache.maven.project.MavenProject p) throws org.apache.maven.plugin.MojoExecutionException
- Parameters:
p
-MavenProject
not null- Returns:
- the compile or test resources
- Throws:
org.apache.maven.plugin.MojoExecutionException
- in case of an error.
-
packageSources
protected void packageSources(org.apache.maven.project.MavenProject p) throws org.apache.maven.plugin.MojoExecutionException
- Parameters:
p
-MavenProject
- Throws:
org.apache.maven.plugin.MojoExecutionException
- in case of an error.
-
packageSources
protected void packageSources(List<org.apache.maven.project.MavenProject> theProjects) throws org.apache.maven.plugin.MojoExecutionException
- Parameters:
theProjects
-MavenProject
- Throws:
org.apache.maven.plugin.MojoExecutionException
- in case of an error.
-
archiveProjectContent
protected void archiveProjectContent(org.apache.maven.project.MavenProject p, org.codehaus.plexus.archiver.Archiver archiver) throws org.apache.maven.plugin.MojoExecutionException
- Parameters:
p
-MavenProject
archiver
-Archiver
- Throws:
org.apache.maven.plugin.MojoExecutionException
- in case of an error.
-
createArchiver
protected org.apache.maven.archiver.MavenArchiver createArchiver() throws org.apache.maven.plugin.MojoExecutionException
- Returns:
MavenArchiver
- Throws:
org.apache.maven.plugin.MojoExecutionException
- in case of an error.
-
addDirectory
protected void addDirectory(org.codehaus.plexus.archiver.Archiver archiver, File sourceDirectory, String[] pIncludes, String[] pExcludes) throws org.apache.maven.plugin.MojoExecutionException
- Parameters:
archiver
-Archiver
sourceDirectory
-File
pIncludes
- The list of includes.pExcludes
- The list of excludes.- Throws:
org.apache.maven.plugin.MojoExecutionException
- in case of an error.
-
addDirectory
protected void addDirectory(org.codehaus.plexus.archiver.Archiver archiver, File sourceDirectory, String prefix, String[] pIncludes, String[] pExcludes) throws org.apache.maven.plugin.MojoExecutionException
- Parameters:
archiver
-Archiver
sourceDirectory
-File
prefix
- The prefix.pIncludes
- the includes.pExcludes
- the excludes.- Throws:
org.apache.maven.plugin.MojoExecutionException
- in case of an error.
-
getExtension
protected String getExtension()
- Returns:
- The extension
.jar
-
getProject
protected org.apache.maven.project.MavenProject getProject(org.apache.maven.project.MavenProject p)
- Parameters:
p
-MavenProject
- Returns:
- The execution projet.
-
getType
protected String getType()
- Returns:
- The type
java-source
-
getProject
protected org.apache.maven.project.MavenProject getProject()
- Returns:
- The current project.
-
setProject
protected void setProject(org.apache.maven.project.MavenProject project)
- Parameters:
project
-MavenProject
-
-