建.将 Maven javah 任务写入 gradle



我怎样才能将Maven Javah任务写成gradle。我有下面的 POM 文件,我需要将其隐蔽到 gradle 中,但我被困住了,我怎么能将 Javah 任务写成 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>

非常粗糙,但足以让你入门,我假设javah生成代码。

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'
}

最新更新