Package org.apache.maven.plugins.source
Class AbstractSourceJarMojo
java.lang.Object
org.apache.maven.plugins.source.AbstractSourceJarMojo
- All Implemented Interfaces:
org.apache.maven.api.plugin.Mojo
- Direct Known Subclasses:
SourceJarNoForkMojo,TestSourceJarNoForkMojo
public abstract class AbstractSourceJarMojo
extends Object
implements org.apache.maven.api.plugin.Mojo
Base class for bundling sources into a jar archive.
- Since:
- 2.0.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.maven.archiver.MavenArchiveConfigurationThe archive configuration to use.protected booleanSpecifies whether to attach the artifact to the projectprotected PathPath to the default MANIFEST file to use.protected booleanSpecifies whether to exclude resources from the sources-jar.protected String[]List of files to exclude.protected StringThe filename to be used for the generated archive file.protected booleanWhether creating the archive should be forced.protected booleanSpecifies whether to include the POM file in the sources-jar.protected String[]List of files to include.protected org.codehaus.plexus.archiver.jar.JarArchiverThe Jar archiver.protected org.apache.maven.api.plugin.Logprotected PathThe directory where the generated archive file will be put.protected StringTimestamp for reproducible output archive entries, either formatted as ISO 8601yyyy-MM-dd'T'HH:mm:ssXXXor as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).protected org.apache.maven.api.ProjectThe Maven Project Objectprotected org.apache.maven.api.services.ProjectManagerUsed for attaching the source jar to the project.protected List<org.apache.maven.api.Project> Contains the full list of projects in the reactor.protected org.apache.maven.api.SessionThe Maven session.protected booleanA flag used to disable the source procedure.protected booleanExclude commonly excluded files such as SCM configuration.protected booleanSet this totrueto enable the use of thedefaultManifestFile. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddDirectory(org.codehaus.plexus.archiver.Archiver archiver, Path sourceDirectory, String[] pIncludes, String[] pExcludes) protected voidaddDirectory(org.codehaus.plexus.archiver.Archiver archiver, Path sourceDirectory, String prefix, String[] pIncludes, String[] pExcludes) protected voidarchiveProjectContent(org.apache.maven.api.Project project, org.codehaus.plexus.archiver.Archiver archiver) protected org.apache.maven.archiver.MavenArchiverprotected voidvoidexecute()protected abstract Stringprotected Stringorg.apache.maven.api.plugin.LoggetLog()protected org.apache.maven.api.Projectprotected org.apache.maven.api.ProjectgetProject(org.apache.maven.api.Project p) protected abstract List<org.apache.maven.api.model.Resource> getResources(org.apache.maven.api.Project p) getSources(org.apache.maven.api.Project p) protected StringgetType()protected voidpackageSources(List<org.apache.maven.api.Project> theProjects) protected voidpackageSources(org.apache.maven.api.Project p) protected voidsetProject(org.apache.maven.api.Project project)
-
Field Details
-
includes
List of files to include. Specified as fileset patterns which are relative to the input directory whose contents is being packaged into the JAR.- Since:
- 2.1
-
excludes
List of files to exclude. Specified as fileset patterns which are relative to the input directory whose contents is being packaged into the JAR.- Since:
- 2.1
-
useDefaultExcludes
@Parameter(property="maven.source.useDefaultExcludes", defaultValue="true") protected boolean useDefaultExcludesExclude commonly excluded files such as SCM configuration. These are defined in the plexus FileUtils.getDefaultExcludes()- Since:
- 2.1
-
project
@Inject protected org.apache.maven.api.Project projectThe Maven Project Object -
jarArchiver
@Inject protected org.codehaus.plexus.archiver.jar.JarArchiver jarArchiverThe Jar archiver. -
archive
@Parameter protected org.apache.maven.archiver.MavenArchiveConfiguration archiveThe archive configuration to use. See Maven Archiver Reference.
Note: Since 3.0.0 the resulting archives contain a maven descriptor. If you need to suppress the generation of the maven descriptor you can simply achieve this by using the archiver configuration..- Since:
- 2.1
-
defaultManifestFile
@Parameter(defaultValue="${project.build.outputDirectory}/META-INF/MANIFEST.MF", readonly=false, required=true) protected Path defaultManifestFilePath to the default MANIFEST file to use. It will be used ifuseDefaultManifestFileis set totrue.- Since:
- 2.1
-
useDefaultManifestFile
@Parameter(property="maven.source.useDefaultManifestFile", defaultValue="false") protected boolean useDefaultManifestFileSet this totrueto enable the use of thedefaultManifestFile.- Since:
- 2.1
-
attach
@Parameter(property="maven.source.attach", defaultValue="true") protected boolean attachSpecifies whether to attach the artifact to the project -
excludeResources
@Parameter(property="maven.source.excludeResources", defaultValue="false") protected boolean excludeResourcesSpecifies whether 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 includePomSpecifies whether to include the POM file in the sources-jar.- Since:
- 2.1
-
outputDirectory
The directory where the generated archive file will be put. -
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="${session.projects}", readonly=true) protected List<org.apache.maven.api.Project> reactorProjectsContains the full list of projects in the reactor. -
forceCreation
@Parameter(property="maven.source.forceCreation", defaultValue="false") protected boolean forceCreationWhether creating the archive should be forced. If set to true, the jar will always be created. If set to false, the jar will only be created when the sources are newer than the jar.- Since:
- 2.1
-
skipSource
@Parameter(property="maven.source.skip", defaultValue="false") protected boolean skipSourceA flag used to disable the source procedure. This is primarily intended for usage from the command line to occasionally adjust the build.- Since:
- 2.2
-
session
@Inject protected org.apache.maven.api.Session sessionThe Maven session. -
outputTimestamp
Timestamp for reproducible output archive entries, either formatted as ISO 8601yyyy-MM-dd'T'HH:mm:ssXXXor as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).- Since:
- 3.2.0
-
log
@Inject protected org.apache.maven.api.plugin.Log log -
projectManager
protected org.apache.maven.api.services.ProjectManager projectManagerUsed for attaching the source jar to the project.
-
-
Constructor Details
-
AbstractSourceJarMojo
public AbstractSourceJarMojo()
-
-
Method Details
-
getLog
public org.apache.maven.api.plugin.Log getLog() -
execute
public void execute() throws org.apache.maven.api.plugin.MojoException- Specified by:
executein interfaceorg.apache.maven.api.plugin.Mojo- Throws:
org.apache.maven.api.plugin.MojoException
-
doExecute
protected void doExecute() -
getClassifier
- Returns:
- the wanted classifier, ie
sourcesortest-sources
-
getSources
protected abstract List<Path> getSources(org.apache.maven.api.Project p) throws org.apache.maven.api.plugin.MojoException - Parameters:
p-Projectnot null- Returns:
- the compile or test sources
- Throws:
org.apache.maven.api.plugin.MojoException- in case of an error.
-
getResources
protected abstract List<org.apache.maven.api.model.Resource> getResources(org.apache.maven.api.Project p) throws org.apache.maven.api.plugin.MojoException - Parameters:
p-Projectnot null- Returns:
- the compile or test resources
- Throws:
org.apache.maven.api.plugin.MojoException- in case of an error.
-
packageSources
protected void packageSources(org.apache.maven.api.Project p) throws org.apache.maven.api.plugin.MojoException - Parameters:
p-Project- Throws:
org.apache.maven.api.plugin.MojoException- in case of an error.
-
packageSources
protected void packageSources(List<org.apache.maven.api.Project> theProjects) throws org.apache.maven.api.plugin.MojoException - Parameters:
theProjects-Project- Throws:
org.apache.maven.api.plugin.MojoException- in case of an error.
-
archiveProjectContent
protected void archiveProjectContent(org.apache.maven.api.Project project, org.codehaus.plexus.archiver.Archiver archiver) throws org.apache.maven.api.plugin.MojoException - Parameters:
project-Projectarchiver-Archiver- Throws:
org.apache.maven.api.plugin.MojoException- in case of an error.
-
createArchiver
protected org.apache.maven.archiver.MavenArchiver createArchiver() throws org.apache.maven.api.plugin.MojoException- Returns:
MavenArchiver- Throws:
org.apache.maven.api.plugin.MojoException- in case of an error.
-
addDirectory
protected void addDirectory(org.codehaus.plexus.archiver.Archiver archiver, Path sourceDirectory, String[] pIncludes, String[] pExcludes) throws org.apache.maven.api.plugin.MojoException - Parameters:
archiver-ArchiversourceDirectory-PathpIncludes- The list of includes.pExcludes- The list of excludes.- Throws:
org.apache.maven.api.plugin.MojoException- in case of an error.
-
addDirectory
protected void addDirectory(org.codehaus.plexus.archiver.Archiver archiver, Path sourceDirectory, String prefix, String[] pIncludes, String[] pExcludes) throws org.apache.maven.api.plugin.MojoException - Parameters:
archiver-ArchiversourceDirectory-Pathprefix- The prefix.pIncludes- the includes.pExcludes- the excludes.- Throws:
org.apache.maven.api.plugin.MojoException- in case of an error.
-
getExtension
- Returns:
- The extension
.jar
-
getProject
protected org.apache.maven.api.Project getProject(org.apache.maven.api.Project p) - Parameters:
p-Project- Returns:
- The execution projet.
-
getType
- Returns:
- The type
java-source
-
getProject
protected org.apache.maven.api.Project getProject()- Returns:
- The current project.
-
setProject
protected void setProject(org.apache.maven.api.Project project) - Parameters:
project-Project
-