0

我如何将 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>
4

1 回答 1

0

非常粗糙但足以让您入门,我假设 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'
}
于 2015-05-01T01:02:25.603 回答