Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在gradle中使用fmpp生成java文件_Gradle_Freemarker_Fmpp - Fatal编程技术网

在gradle中使用fmpp生成java文件

在gradle中使用fmpp生成java文件,gradle,freemarker,fmpp,Gradle,Freemarker,Fmpp,我有一个现有的maven项目,我正试图移植到gradle 一个子模块使用fmpp/freemarker生成大量java文件,然后反馈到构建中 我是gradle的新手,我想知道是否有人知道一种简单的方法 任何帮助都将不胜感激 我当前的pom.xml如下所示: <build> <plugins> <!-- Freemarker maven plugin for code generation --> <plugin&g

我有一个现有的maven项目,我正试图移植到gradle

一个子模块使用fmpp/freemarker生成大量java文件,然后反馈到构建中

我是gradle的新手,我想知道是否有人知道一种简单的方法

任何帮助都将不胜感激

我当前的pom.xml如下所示:

<build>
    <plugins>
        <!-- Freemarker maven plugin for code generation -->
        <plugin>
            <groupId>com.googlecode.fmpp-maven-plugin</groupId>
            <artifactId>fmpp-maven-plugin</artifactId>
            <version>1.0</version>
            <dependencies>
                <dependency>
                    <groupId>org.unix4j</groupId>
                    <artifactId>unix4j-tools</artifactId>
                    <version>0.1-SNAPSHOT</version>
                    <optional>true</optional>
                </dependency>
            </dependencies>
            <configuration>
                <cfgFile>src/main/resources/codegen/config.fmpp</cfgFile>
                <outputDirectory>target/generated-sources/main/java</outputDirectory>
                <templateDirectory>src/main/resources/codegen/templates</templateDirectory>
            </configuration>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>src/main/generated</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

com.googlecode.fmpp-maven-plugin
fmppmaven插件
1
org.unix4j
unix4j工具
0.1-1快照
真的
src/main/resources/codegen/config.fmpp
目标/生成的源代码/main/java
src/main/resources/codegen/templates
生成源
生成
org.codehaus.mojo
构建助手maven插件
生成源
添加源
src/main/generated

对不起,我应该先花更多时间在谷歌上搜索。这是对我有效的解决方案:

project(':unix4j-core:unix4j-command') {
    configurations {pmd}

    dependencies {
        compile project(':unix4j-core:unix4j-base')
        compile project(':unix4j-tools')
        pmd project(':unix4j-tools')
    }

    task generateFmppSources(dependsOn: ":unix4j-tools:compileJava") << {
        println "Generating sources...."
        ant.taskdef(name:'fmpp', classname:'fmpp.tools.AntTask', classpath:configurations.pmd.asPath);
        ant.fmpp configuration:"src/main/resources/codegen/config.fmpp", sourceRoot:"src/main/resources/codegen/templates", outputRoot:"target/generated-sources/main/java";
    }
    compileJava.dependsOn generateFmppSources
    sourceSets {
        main {
            java {
                srcDir 'target/generated-sources/main/java'
            }
        }
    }
}
project(“:unix4j核心:unix4j命令”){
配置{pmd}
依赖关系{
编译项目(':unix4j core:unix4j base')
编译项目(“:unix4j工具”)
pmd项目(“:unix4j工具”)
}
任务生成MPPSources(dependsOn::unix4j工具:compileJava)