public class ShadeMojo extends AbstractMojo implements org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable
| Modifier and Type | Field and Description |
|---|---|
protected ArtifactResolver |
artifactResolver
Artifact resolver, needed to download source jars for inclusion in classpath.
|
protected ArtifactSet |
artifactSet
Artifacts to include/exclude from the final artifact.
|
protected boolean |
createDependencyReducedPom
Flag whether to generate a simplified POM for the shaded artifact.
|
protected boolean |
createSourcesJar
When true, it will attempt to create a sources jar as well
|
protected boolean |
createTestSourcesJar
When true, it will attempt to create a test sources jar.
|
protected DependencyGraphBuilder |
dependencyGraphBuilder
The dependency graph builder to use.
|
protected File |
dependencyReducedPomLocation
Where to put the dependency reduced pom.
|
protected ArchiveFilter[] |
filters
Archive Filters to be used.
|
protected String |
finalName
The name of the shaded artifactId.
|
protected boolean |
generateUniqueDependencyReducedPom
Create a dependency-reduced POM in ${basedir}/drp-UNIQUE.pom.
|
protected boolean |
keepDependenciesWithProvidedScope
When true, dependencies are kept in the pom but with scope 'provided'; when false, the dependency is removed.
|
protected ArtifactRepository |
localRepository
Local maven repository.
|
protected boolean |
minimizeJar
When true, dependencies will be stripped down on the class level to only the transitive hull required for the
artifact.
|
protected File |
outputDirectory
The destination directory for the shaded artifact.
|
protected File |
outputFile
The path to the output file for the shaded artifact.
|
protected org.codehaus.plexus.PlexusContainer |
plexusContainer |
protected MavenProject |
project
The current Maven project.
|
protected ProjectBuilder |
projectBuilder
ProjectBuilder, needed to create projects from the artifacts.
|
protected MavenProjectHelper |
projectHelper |
protected boolean |
promoteTransitiveDependencies
When true, transitive deps of removed dependencies are promoted to direct dependencies.
|
protected PackageRelocation[] |
relocations
Packages to be relocated.
|
protected List<ArtifactRepository> |
remoteArtifactRepositories
Remote repositories which will be searched for source attachments.
|
protected MavenSession |
session
The current Maven session.
|
protected boolean |
shadedArtifactAttached
Defines whether the shaded artifact should be attached as classifier to the original artifact.
|
protected String |
shadedArtifactId
The name of the shaded artifactId.
|
protected String |
shadedClassifierName
The name of the classifier used in case the shaded artifact is attached.
|
protected String |
shadedGroupFilter
If specified, this will include only artifacts which have groupIds which start with this.
|
protected Shader |
shader |
protected String |
shaderHint
You can pass here the roleHint about your own Shader implementation plexus component.
|
protected boolean |
shadeSourcesContent
When true, it will attempt to shade the contents of the java source files when creating the sources jar.
|
protected boolean |
shadeTestJar
When true, creates a shaded test-jar artifact as well.
|
protected boolean |
skipShade
When true, skips shading all artifacts.
|
protected ResourceTransformer[] |
transformers
Resource transformers to be used.
|
protected boolean |
useBaseVersion
When true, the version of each dependency of the reduced pom will be based on the baseVersion of the original
dependency instead of its resolved version.
|
| Constructor and Description |
|---|
ShadeMojo() |
getLog, getPluginContext, setLog, setPluginContext@Parameter(defaultValue="${session}", readonly=true, required=true) protected MavenSession session
@Parameter(defaultValue="${project}", readonly=true, required=true) protected MavenProject project
@Component protected MavenProjectHelper projectHelper
@Component(hint="default", role=Shader.class) protected Shader shader
@Component protected DependencyGraphBuilder dependencyGraphBuilder
@Component protected ProjectBuilder projectBuilder
@Parameter(readonly=true, required=true, defaultValue="${project.remoteArtifactRepositories}") protected List<ArtifactRepository> remoteArtifactRepositories
@Parameter(readonly=true, required=true, defaultValue="${localRepository}") protected ArtifactRepository localRepository
@Component protected ArtifactResolver artifactResolver
@Parameter protected ArtifactSet artifactSet
groupId:artifactId:type:classifier. Since version 1.3, the wildcard characters '*' and
'?' can be used within the sub parts of those composite identifiers to do pattern matching. For convenience, the
syntax groupId is equivalent to groupId:*:*:*, groupId:artifactId is
equivalent to groupId:artifactId:*:* and groupId:artifactId:classifier is equivalent to
groupId:artifactId:*:classifier. For example:
<artifactSet>
<includes>
<include>org.apache.maven:*</include>
</includes>
<excludes>
<exclude>*:maven-core</exclude>
</excludes>
</artifactSet>
@Parameter protected PackageRelocation[] relocations
<relocations>
<relocation>
<pattern>org.apache</pattern>
<shadedPattern>hidden.org.apache</shadedPattern>
<includes>
<include>org.apache.maven.*</include>
</includes>
<excludes>
<exclude>org.apache.maven.Public*</exclude>
</excludes>
</relocation>
</relocations>
Note: Support for includes exists only since version 1.4.@Parameter protected ResourceTransformer[] transformers
@Parameter protected ArchiveFilter[] filters
artifactSet and a set of include/exclude file patterns for filtering which contents of the archive are
added to the shaded jar. From a logical perspective, includes are processed before excludes, thus it's possible
to use an include to collect a set of files from the archive then use excludes to further reduce the set. By
default, all files are included and no files are excluded. If multiple filters apply to an artifact, the
intersection of the matched files will be included in the final JAR. For example:
<filters>
<filter>
<artifact>junit:junit</artifact>
<includes>
<include>org/junit/**</include>
</includes>
<excludes>
<exclude>org/junit/experimental/**</exclude>
</excludes>
</filter>
</filters>
@Parameter(defaultValue="${project.build.directory}") protected File outputDirectory
@Parameter protected String finalName
@Parameter(defaultValue="${project.artifactId}") protected String shadedArtifactId
@Parameter protected String shadedGroupFilter
@Parameter protected boolean shadedArtifactAttached
@Parameter(defaultValue="true") protected boolean createDependencyReducedPom
true, dependencies that
have been included into the uber JAR will be removed from the <dependencies> section of the
generated POM. The reduced POM will be named dependency-reduced-pom.xml and is stored into the same
directory as the shaded artifact. Unless you also specify dependencyReducedPomLocation, the plugin will create a
temporary file named dependency-reduced-pom.xml in the project basedir.@Parameter(defaultValue="${basedir}/dependency-reduced-pom.xml") protected File dependencyReducedPomLocation
@Parameter(defaultValue="false") protected boolean generateUniqueDependencyReducedPom
@Parameter protected boolean keepDependenciesWithProvidedScope
@Parameter protected boolean promoteTransitiveDependencies
@Parameter(defaultValue="shaded") protected String shadedClassifierName
@Parameter protected boolean createSourcesJar
@Parameter protected boolean createTestSourcesJar
@Parameter(property="shadeSourcesContent", defaultValue="false") protected boolean shadeSourcesContent
@Parameter protected boolean minimizeJar
@Parameter protected File outputFile
finalName, shadedArtifactAttached, shadedClassifierName and
createDependencyReducedPom to be ignored when used.@Parameter protected String shaderHint
@Parameter(defaultValue="false") protected boolean useBaseVersion
@Parameter(defaultValue="false") protected boolean shadeTestJar
@Parameter(defaultValue="false") protected boolean skipShade
protected org.codehaus.plexus.PlexusContainer plexusContainer
public void contextualize(org.codehaus.plexus.context.Context context)
throws org.codehaus.plexus.context.ContextException
contextualize in interface org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizableorg.codehaus.plexus.context.ContextExceptionpublic void execute()
throws MojoExecutionException
execute in interface MojoMojoExecutionException - in case of an error.protected void createErrorOutput()
protected ShadeRequest shadeRequest(String shade, Set<File> artifacts, File outputJar, List<Filter> filters, List<Relocator> relocators, List<ResourceTransformer> resourceTransformers)
protected ShadeRequest createShadeSourcesRequest(String shade, Set<File> testArtifacts, File testJar, List<Filter> filters, List<Relocator> relocators, List<ResourceTransformer> resourceTransformers)
protected void setupHintedShader()
throws MojoExecutionException
MojoExecutionExceptionprotected void processArtifactSelectors(Set<File> artifacts, Set<String> artifactIds, Set<File> sourceArtifacts, Set<File> testArtifacts, Set<File> testSourceArtifacts, org.apache.maven.plugins.shade.mojo.ArtifactSelector artifactSelector)
protected boolean invalidMainArtifact()
protected void replaceFile(File oldFile, File newFile) throws MojoExecutionException
MojoExecutionExceptionprotected void copyFiles(File source, File target) throws IOException
IOExceptionprotected File resolveArtifactForClassifier(Artifact artifact, String classifier)
protected List<ResourceTransformer> getResourceTransformers()
protected List<Filter> getFilters() throws MojoExecutionException
MojoExecutionExceptionprotected File shadedArtifactFileWithClassifier()
protected File shadedSourceArtifactFileWithClassifier()
protected File shadedTestSourceArtifactFileWithClassifier()
protected File shadedTestArtifactFileWithClassifier()
protected File shadedSourcesArtifactFile()
protected File shadedTestSourcesArtifactFile()
protected File shadedTestArtifactFile()
protected void createDependencyReducedPom(Set<String> artifactsToRemove) throws IOException, DependencyGraphBuilderException, ProjectBuildingException
protected void rewriteDependencyReducedPomIfWeHaveReduction(List<Dependency> dependencies, boolean modified, List<Dependency> transitiveDeps, Model model) throws IOException, ProjectBuildingException, DependencyGraphBuilderException
protected void removeSystemScopedDependencies(Set<String> artifactsToRemove, List<Dependency> originalDependencies)
protected void addSystemScopedDependencyFromNonInterpolatedPom(List<Dependency> dependencies, List<Dependency> originalDependencies)
protected Dependency createDependency(Artifact artifact)
protected String getId(Dependency dependency)
public boolean updateExcludesInDeps(MavenProject project, List<Dependency> dependencies, List<Dependency> transitiveDeps) throws DependencyGraphBuilderException
DependencyGraphBuilderExceptionprotected List<ResourceTransformer> toResourceTransformers(String shade, List<ResourceTransformer> resourceTransformers)
Copyright © 2002–2022 The Apache Software Foundation. All rights reserved.