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) public class AddModuleInfoMojo extends org.apache.maven.plugin.AbstractMojo
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
AddModuleInfoMojo.InstantConverter
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
artifactId
private java.io.File
buildDirectory
private java.util.List<org.apache.maven.model.Exclusion>
exclusions
private boolean
failOnWarning
private java.util.List<java.lang.String>
jdepsExtraArgs
private java.lang.String
jvmVersion
private MainModuleConfiguration
module
private static java.lang.String
MODULE_INFO_CLASS
private java.util.List<ModuleConfiguration>
modules
private java.io.File
outputDirectory
private java.lang.String
outputTimestamp
Timestamp for reproducible output archive entries, either formatted as ISO 8601 extended offset date-time (e.g.private boolean
overwriteExistingFiles
protected org.apache.maven.project.MavenProject
project
private java.util.List<org.eclipse.aether.repository.RemoteRepository>
remoteRepos
private org.eclipse.aether.RepositorySystemSession
repoSession
private org.eclipse.aether.RepositorySystem
repoSystem
private boolean
skip
private java.lang.String
version
private static java.util.regex.Pattern
VERSIONED_MODULE_INFO
private java.io.File
workingDirectory
-
Constructor Summary
Constructors Constructor Description AddModuleInfoMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
createDirectories()
private java.lang.String
determineVersion(ArtifactConfiguration artifact)
void
execute()
private java.lang.String
getAssignedModuleName(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.Path
getInputFile(ModuleConfiguration moduleConfiguration, ArtifactResolutionHelper artifactResolutionHelper)
private java.lang.String
getLines(java.nio.file.Path file)
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)
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)
private java.lang.String
getVersion(ModuleConfiguration moduleConfiguration)
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.private void
resolveArtifactsToBeModularized(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 outputTimestamp
Timestamp 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.MojoExecutionException
org.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)
-
-