Maven-war-plugin也运行其他执行(jooq-codegen-maven)

时间:2018-03-08 21:53:46

标签: java maven intellij-idea jooq

目标
在我的pom.xml中,我希望有一个插件可以从我的项目中创建一个战争。另外,我想要一个为我的项目生成数据库文件的插件。

使用过的插件
maven-war-plugin和jooq-codegen-maven。

问题
每当我启动我的maven-war-plugin时,它也会启动我的jooq插件。这意味着我在生成战争之前就生成了新的数据库类。这是一个问题,因为它可能会产生一些我无法追踪的令人讨厌的错误。

我尝试了什么
我尝试添加到jOOQ插件,但这使得它在我执行插件本身时也会跳过。所以我真的不知道如何解决它。

的pom.xml

#include <iostream>
#include <string>
#include <fstream>

bool read_month_name(std::ifstream &, std::string &);
bool read_num_days(std::ifstream &, int &);

int main() {

    // make test file
    std::ofstream ofs("infile.txt");
    ofs << R"(January 31
February 28
March 31
April 30
May 31
June 30
July 31
August 31
September 30
October 31
November 30
December 31)";
    ofs.close();


    std::string month_name;
    int num_of_days;

    std::ifstream myfile;
    myfile.open("infile.txt");


    for (int i = 0; i < 20; ++i) 
    {
        if (read_month_name(myfile, month_name) && read_num_days(myfile, num_of_days))
            std::cout << "There are " << num_of_days << " days in " << month_name << ".\n";
        else
            break;
    }
}

bool read_month_name(std::ifstream &myfile, std::string &month)
{
    return myfile >> month ? true : false;
}

bool read_num_days(std::ifstream &myfile, int &days)
{
    return myfile >> days ? true : false;
}

执行日志maven-war-plugin(mvn install)

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.7.0</version>
            <configuration>
                <!-- or whatever version you use -->
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>3.2.0</version>
            <configuration>
                <webResources>
                    <resource>
                        <!-- Add the webapp dir (otherwise web.xml and context.xml are not picked up)  -->
                        <directory>${project.basedir}/webapp</directory>
                    </resource>
                    <resource>
                        <directory>${project.basedir}/../Angular/dist</directory>
                    </resource>
                </webResources>

                <warSourceDirectory>WebContent</warSourceDirectory>
                <failOnMissingWebXml>true</failOnMissingWebXml>
            </configuration>
        </plugin>

        <!-- Plugin for generating jOOQ classes. -->
        <plugin>
            <groupId>org.jooq</groupId>
            <artifactId>jooq-codegen-maven</artifactId>
            <version>${jooq.version}</version>

            <executions>
                <execution>
                    <id>jooq-codegen</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>

            <configuration>
                <!-- <skip>true</skip> -->
                <jdbc>
                    <driver>com.mysql.jdbc.Driver</driver>
                    <url>${url.database}</url>
                    <user>root</user>
                    <password>rootie</password>
                </jdbc>
                <generator>
                    <!-- Use my own GeneratorStrategy to make naming easier. -->
                    <strategy>
                        <name>com.apon.database.jooq.GeneratorStrategy</name>
                    </strategy>
                    <database>
                        <name>org.jooq.util.mysql.MySQLDatabase</name>
                        <includes>.*</includes>
                        <!-- <excludes></excludes> -->
                        <inputSchema>taalmaatjes</inputSchema>
                        <!-- Boolean en bytes zijn gek -->
                        <forcedTypes>
                            <forcedType>
                                <name>BOOLEAN</name>
                                <types>tinyint</types>
                            </forcedType>
                        </forcedTypes>
                    </database>
                    <target>
                        <packageName>com.apon.database.generated</packageName>
                        <directory>src/main/java</directory>
                    </target>

                    <generate>
                        <pojos>true</pojos>
                        <daos>true</daos>
                        <interfaces>false</interfaces>
                    </generate>
                </generator>
            </configuration>
        </plugin>
    </plugins>
</build>

0 个答案:

没有答案