0

How could I write Maven Javah task into gradle.I have below POM file and I need to covert it into gradle but I am stuck how could I write the Javah task into gradle

 <executions>
                            <execution>
                                <id>javah</id>
                                <phase>generate-sources</phase>
                                <configuration>
                                    <javahOS>linux</javahOS>
                                    <javahProvider>default</javahProvider>
                                    <javahOutputDirectory>${project.build.directory}/custom-javah</javahOutputDirectory>
                                    <workingDirectory>${basedir}</workingDirectory>
                                    <javahOutputFileName>MegJniWrapper.h</javahOutputFileName>
                                    <javahClassNames>
                                        <javahClassName>com.abcdefgh.engine.common.meg.MegJniWrapper</javahClassName>
                                    </javahClassNames>
                                </configuration>
                                <goals>
                                    <goal>javah</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
Suman
  • 11
  • 2
unknown
  • 1,815
  • 3
  • 26
  • 51

1 Answers1

0

Very rough but enough to get you started, I'm assuming javah generates code.

ext {
    // define directories here
    // ex. genSrcDir
}
configurations {
        javah
}

// here you want to include it in your sourceset so that if compileJava gets call your generated code will also compile (don't know if that applies to javah)
// ex. sourceSets.main.java.srcDir genSrcDir

dependencies {
  // put javah dependencies here and use javah as configuration
  // ex. javah dependency.jar
}

task javah () {
    description = 'javah task'

    // put optional inputs.dir and outputs.dir here so gradle can skip if nothing changes

    doLast {
      // javaexec here to call the javah
    }
}

compileJava.dependsOn javah

task generateSource (dependsOn: javah) {
    description = 'Javah'
}
Al Jacinto
  • 300
  • 2
  • 7