Class NativeJavahMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="javah",
          defaultPhase=GENERATE_SOURCES,
          requiresDependencyResolution=COMPILE)
    public class NativeJavahMojo
    extends AbstractNativeMojo
    Generate JNI include files based on a set of class names
    • Field Detail

      • javahProvider

        @Parameter(defaultValue="default",
                   required=true)
        private java.lang.String javahProvider
        Javah Provider.
        Since:
        1.0-alpha-2
      • javahClassNames

        @Parameter
        private java.util.List<java.lang.String> javahClassNames
        List of class names to generate native files. Additional JNI interface will automatically discovered from project's dependencies of jar type, when javahSearchJNIFromDependencies is true
        Since:
        1.0-alpha-4
      • javahSearchJNIFromDependencies

        @Parameter(defaultValue="false")
        private boolean javahSearchJNIFromDependencies
        Enable the search from project dependencies for JNI interfaces, in addition to javahClassNames
        Since:
        1.0-alpha-4
      • javahPath

        @Parameter
        private java.io.File javahPath
        Path to javah executable, if present, it will override the default one which bases on architecture type. See 'javahProvider' argument
        Since:
        1.0-alpha-2
      • javahOutputDirectory

        @Parameter(defaultValue="${project.build.directory}/native/javah",
                   required=true)
        protected java.io.File javahOutputDirectory
        Where to place javah generated file
        Since:
        1.0-alpha-2
      • javahOutputFileName

        @Parameter
        private java.lang.String javahOutputFileName
        if configured, this value will be combined with outputDirectory to pass into javah's -o option
        Since:
        1.0-alpha-4
      • javahIncludes

        @Parameter
        private java.util.List<JavahInclude> javahIncludes
        Additional javah classname and its corresponding header name. Use this option to create one class per header

         <javahIncludes>
           <javahInclude>
             <className>com.some.Class</className>
             <headerName>Class.h</headerName>
           <javahInclude>
         </javahIncludes>
         
        Since:
        1.0-alpha-8
      • javahVerbose

        @Parameter(defaultValue="false")
        private boolean javahVerbose
        Enable javah verbose mode
        Since:
        1.0-alpha-2
      • attach

        @Parameter(defaultValue="false")
        private boolean attach
        Archive all generated include files and deploy as an inczip
      • classifier

        @Parameter(defaultValue="javah")
        private java.lang.String classifier
        Classifier name when install/deploy generated includes file. See ${attach} for details
      • incZipFile

        @Parameter(defaultValue="${project.build.directory}/${project.build.finalName}.inczip",
                   required=true)
        private java.io.File incZipFile
        Archive file to bundle all generated include files if enable by ${attach}
        Since:
        1.0-alpha-8
      • useEnvClasspath

        @Parameter(defaultValue="false")
        private boolean useEnvClasspath
        Set CLASSPATH env variable instead of using -classpath command-line argument. Use this option to allow large number of jars in classpath due to command line size limit under Windows
        Since:
        1.0-alpha-9
      • manager

        @Component
        private JavahManager manager
        Internal: To look up javah implementation
        Since:
        1.0-alpha-2
      • projectHelper

        @Component
        private org.apache.maven.project.MavenProjectHelper projectHelper
        Maven ProjectHelper.
        Since:
        1.0-alpha-8
    • Constructor Detail

      • NativeJavahMojo

        public NativeJavahMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • attachGeneratedIncludeFilesAsIncZip

        private void attachGeneratedIncludeFilesAsIncZip()
                                                  throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getJavah

        private Javah getJavah()
                        throws org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • getJavahArtifacts

        private java.util.List<org.apache.maven.artifact.Artifact> getJavahArtifacts()
        Get all jars in the pom excluding transitive, test, and provided scope dependencies.
        Returns:
      • getJavahClassPath

        private java.lang.String[] getJavahClassPath()
        Build classpaths from dependent jars including project output directory (i.e. classes directory )
        Returns:
      • discoverAdditionalJNIClassName

        private void discoverAdditionalJNIClassName()
                                             throws org.apache.maven.plugin.MojoExecutionException
        Get applicable class names to be "javahed"
        Throws:
        org.apache.maven.plugin.MojoExecutionException
      • createProviderConfiguration

        private JavahConfiguration createProviderConfiguration​(java.lang.String[] classNames,
                                                               java.lang.String javahOutputFileName)
      • getJavahConfiguration

        protected JavahConfiguration getJavahConfiguration()
        Internal only for test harness purpose
        Returns:
      • getProject

        protected org.apache.maven.project.MavenProject getProject()
        Internal for unit test only
        Overrides:
        getProject in class AbstractNativeMojo