Class 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
    • 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
      • exclusions

        @Parameter
        private java.util.List<org.apache.maven.model.Exclusion> exclusions
      • jdepsExtraArgs

        @Parameter
        private java.util.List<java.lang.String> jdepsExtraArgs
    • Constructor Detail

      • AddModuleInfoMojo

        public AddModuleInfoMojo()
    • 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)