Package org.moditect.mavenplugin.add
Class AddModuleInfoMojo
- java.lang.Object
-
- org.apache.maven.plugin.AbstractMojo
-
- org.moditect.mavenplugin.add.AddModuleInfoMojo
-
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled,org.apache.maven.plugin.Mojo
@Mojo(name="add-module-info", defaultPhase=PROCESS_RESOURCES, requiresDependencyResolution=COMPILE_PLUS_RUNTIME, threadSafe=true) public class AddModuleInfoMojo extends org.apache.maven.plugin.AbstractMojo
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.StringartifactIdprivate java.io.FilebuildDirectoryprivate java.util.List<org.apache.maven.model.Exclusion>exclusionsprivate booleanfailOnWarningprivate java.util.List<java.lang.String>jdepsExtraArgsprivate java.lang.StringjvmVersionprivate MainModuleConfigurationmoduleprivate static java.lang.StringMODULE_INFO_CLASSprivate java.util.List<ModuleConfiguration>modulesprivate java.io.FileoutputDirectoryprivate java.lang.StringoutputTimestampTimestamp for reproducible output archive entries, either formatted as ISO 8601 extended offset date-time (e.g.private booleanoverwriteExistingFilesprotected org.apache.maven.project.MavenProjectprojectprivate java.util.List<org.eclipse.aether.repository.RemoteRepository>remoteReposprivate org.eclipse.aether.RepositorySystemSessionrepoSessionprivate org.eclipse.aether.RepositorySystemrepoSystemprivate booleanskipprivate java.lang.Stringversionprivate static java.util.regex.PatternVERSIONED_MODULE_INFOprivate java.io.FileworkingDirectory
-
Constructor Summary
Constructors Constructor Description AddModuleInfoMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidcreateDirectories()private java.lang.StringdetermineVersion(ArtifactConfiguration artifact)voidexecute()private java.lang.StringgetAssignedModuleName(java.util.Map<ArtifactIdentifier,java.lang.String> assignedNamesByModule, org.apache.maven.artifact.Artifact artifact)private java.util.Map<ArtifactIdentifier,java.lang.String>getAssignedModuleNamesByModule(ArtifactResolutionHelper artifactResolutionHelper)private java.nio.file.PathgetInputFile(ModuleConfiguration moduleConfiguration, ArtifactResolutionHelper artifactResolutionHelper)private java.lang.StringgetLines(java.nio.file.Path file)private java.lang.StringgetModuleInfoSource(java.nio.file.Path inputFile, MainModuleConfiguration moduleConfiguration, ModuleInfoGenerator moduleInfoGenerator, java.util.Map<ArtifactIdentifier,java.lang.String> assignedNamesByModule, java.util.Map<ArtifactIdentifier,java.nio.file.Path> modularizedJars)private java.lang.StringgetModuleInfoSource(java.nio.file.Path inputFile, ModuleConfiguration moduleConfiguration, ModuleInfoGenerator moduleInfoGenerator, java.util.Map<ArtifactIdentifier,java.lang.String> assignedNamesByModule, java.util.Map<ArtifactIdentifier,java.nio.file.Path> modularizedJars)private java.lang.StringgetVersion(ModuleConfiguration moduleConfiguration)private booleanisModularJar(java.nio.file.Path jarPath)Determines if the given JAR is already modular that is, it contains either a "module-info.class" entry or at least one "/META-INF/version/\\d+/module-info.class" entry.private voidresolveArtifactsToBeModularized(ArtifactResolutionHelper artifactResolutionHelper)Sets the resolved artifact of all artifact configurations.
-
-
-
Field Detail
-
MODULE_INFO_CLASS
private static final java.lang.String MODULE_INFO_CLASS
- See Also:
- Constant Field Values
-
VERSIONED_MODULE_INFO
private static final java.util.regex.Pattern VERSIONED_MODULE_INFO
-
repoSystem
@Component private org.eclipse.aether.RepositorySystem repoSystem
-
repoSession
@Parameter(defaultValue="${repositorySystemSession}", readonly=true, required=true) private org.eclipse.aether.RepositorySystemSession repoSession
-
remoteRepos
@Parameter(defaultValue="${project.remoteProjectRepositories}", readonly=true, required=true) private java.util.List<org.eclipse.aether.repository.RemoteRepository> remoteRepos
-
project
@Parameter(defaultValue="${project}", readonly=true) protected org.apache.maven.project.MavenProject project
-
artifactId
@Parameter(defaultValue="${project.artifactId}", readonly=true, required=true) private java.lang.String artifactId
-
version
@Parameter(defaultValue="${project.version}", readonly=true, required=true) private java.lang.String version
-
jvmVersion
@Parameter(property="moditect.jvmVersion") private java.lang.String jvmVersion
-
workingDirectory
@Parameter(readonly=true, defaultValue="${project.build.directory}/moditect") private java.io.File workingDirectory
-
buildDirectory
@Parameter(readonly=true, defaultValue="${project.build.directory}") private java.io.File buildDirectory
-
outputDirectory
@Parameter(property="outputDirectory", defaultValue="${project.build.directory}/modules") private java.io.File outputDirectory
-
overwriteExistingFiles
@Parameter(property="overwriteExistingFiles", defaultValue="false") private boolean overwriteExistingFiles
-
outputTimestamp
@Parameter(defaultValue="${project.build.outputTimestamp}") private java.lang.String outputTimestampTimestamp for reproducible output archive entries, either formatted as ISO 8601 extended offset date-time (e.g. in UTC such as '2011-12-03T10:15:30Z' or with an offset '2019-10-05T20:37:42+06:00'), or as an int representing seconds since the epoch (like SOURCE_DATE_EPOCH).
-
skip
@Parameter(property="moditect.skip", defaultValue="false") private boolean skip
-
failOnWarning
@Parameter(property="moditect.failOnWarning", defaultValue="true") private boolean failOnWarning
-
module
@Parameter private MainModuleConfiguration module
-
modules
@Parameter private java.util.List<ModuleConfiguration> modules
-
exclusions
@Parameter private java.util.List<org.apache.maven.model.Exclusion> exclusions
-
jdepsExtraArgs
@Parameter private java.util.List<java.lang.String> jdepsExtraArgs
-
-
Method Detail
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException- Throws:
org.apache.maven.plugin.MojoExecutionExceptionorg.apache.maven.plugin.MojoFailureException
-
isModularJar
private boolean isModularJar(java.nio.file.Path jarPath)
Determines if the given JAR is already modular that is, it contains either a "module-info.class" entry or at least one "/META-INF/version/\\d+/module-info.class" entry.
-
resolveArtifactsToBeModularized
private void resolveArtifactsToBeModularized(ArtifactResolutionHelper artifactResolutionHelper) throws org.apache.maven.plugin.MojoExecutionException
Sets the resolved artifact of all artifact configurations. If no version is given, we try to obtain it from the project dependencies.- Throws:
org.apache.maven.plugin.MojoExecutionException
-
determineVersion
private java.lang.String determineVersion(ArtifactConfiguration artifact) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getVersion
private java.lang.String getVersion(ModuleConfiguration moduleConfiguration)
-
getInputFile
private java.nio.file.Path getInputFile(ModuleConfiguration moduleConfiguration, ArtifactResolutionHelper artifactResolutionHelper) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getModuleInfoSource
private java.lang.String getModuleInfoSource(java.nio.file.Path inputFile, ModuleConfiguration moduleConfiguration, ModuleInfoGenerator moduleInfoGenerator, java.util.Map<ArtifactIdentifier,java.lang.String> assignedNamesByModule, java.util.Map<ArtifactIdentifier,java.nio.file.Path> modularizedJars) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getModuleInfoSource
private java.lang.String getModuleInfoSource(java.nio.file.Path inputFile, MainModuleConfiguration moduleConfiguration, ModuleInfoGenerator moduleInfoGenerator, java.util.Map<ArtifactIdentifier,java.lang.String> assignedNamesByModule, java.util.Map<ArtifactIdentifier,java.nio.file.Path> modularizedJars) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getLines
private java.lang.String getLines(java.nio.file.Path file) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
createDirectories
private void createDirectories()
-
getAssignedModuleNamesByModule
private java.util.Map<ArtifactIdentifier,java.lang.String> getAssignedModuleNamesByModule(ArtifactResolutionHelper artifactResolutionHelper) throws org.apache.maven.plugin.MojoExecutionException
- Throws:
org.apache.maven.plugin.MojoExecutionException
-
getAssignedModuleName
private java.lang.String getAssignedModuleName(java.util.Map<ArtifactIdentifier,java.lang.String> assignedNamesByModule, org.apache.maven.artifact.Artifact artifact)
-
-