Maven需要在文件更改后每次运行

时间:2016-10-18 14:30:12

标签: java eclipse maven

我的问题:每次更改文件时我都必须运行maven clean site以便Eclipse运行新版本......有人可以帮助我吗?每次运行干净的网站都很烦人。

这是(部分)我的pom文件:

<properties>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>

    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

    <slick2d.version>1.0.2</slick2d.version>
    <junit.version>4.12</junit.version>
    <json.plugin.version>1.1.1</json.plugin.version>
    <mockito.version>1.9.5</mockito.version>
    <findbugs.annotations.version>1.3.2</findbugs.annotations.version>

    <javadoc.plugin.version>2.10.3</javadoc.plugin.version>
    <checkstyle.plugin.version>2.17</checkstyle.plugin.version>
    <pmd.plugin.version>3.6</pmd.plugin.version>
    <findbugs.plugin.version>3.0.3</findbugs.plugin.version>
    <cobertura.plugin.version>2.7</cobertura.plugin.version>
</properties>

<dependencies>
    <dependency> <!-- slick2D dependency -->
        <groupId>org.slick2d</groupId>
        <artifactId>slick2d-core</artifactId>
        <version>${slick2d.version}</version>
    </dependency>

    <dependency> <!-- junit dependency -->
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>${junit.version}</version>
    </dependency>

    <dependency> <!-- json dependency -->
        <groupId>com.googlecode.json-simple</groupId>
        <artifactId>json-simple</artifactId>
        <version>${json.plugin.version}</version>
    </dependency>   

    <dependency> <!-- mockito dependency -->
        <groupId>org.mockito</groupId>
        <artifactId>mockito-all</artifactId>
        <version>${mockito.version}</version>
    </dependency>

    <dependency>
        <groupId>net.sourceforge.findbugs</groupId>
        <artifactId>annotations</artifactId>
        <version>${findbugs.annotations.version}</version>
        <scope>provided</scope>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin> <!-- cobertura -->
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>${cobertura.plugin.version}</version>
            <configuration>
                <instrumentation>
                    <excludes>
                        <exclude>*/CoberturaIgnore.class</exclude>
                        <exclude>*/highscore/HighScore.class</exclude>
                        <exclude>*/pop/PopBehaviour.class</exclude>
                        <exclude>*/ui/*.class</exclude>
                    </excludes>
                    <ignoreMethodAnnotations>
                        <ignoreMethodAnnotation>spiceballs.CoberturaIgnore</ignoreMethodAnnotation>
                    </ignoreMethodAnnotations>
                </instrumentation>
            </configuration>
        </plugin>

        <plugin> <!-- checkstyle -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>${checkstyle.plugin.version}</version>
            <configuration>
                <configLocation>${basedir}/checkstyle.xml</configLocation>
                <includeTestSourceDirectory>true</includeTestSourceDirectory>
            </configuration>
        </plugin>

        <plugin> <!-- pmd -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-pmd-plugin</artifactId>
            <version>${pmd.plugin.version}</version>
            <configuration>
                <skipEmptyReport>false</skipEmptyReport>
                <includeTests>true</includeTests>
                <rulesets>
                    <ruleset>pmd-rules.xml</ruleset>
                </rulesets>
            </configuration>
        </plugin>

        <plugin> <!-- findbugs -->
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>${findbugs.plugin.version}</version>
            <configuration>
                <xmlOutput>true</xmlOutput>
                <includeTests>true</includeTests>
            </configuration>
        </plugin>
    </plugins>
</build>

<reporting>
    <plugins>
        <plugin> <!-- javadoc report -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>${javadoc.plugin.version}</version>
            <configuration>
                <failOnError>false</failOnError>
            </configuration>
            <reportSets>
                <reportSet>
                    <id>default</id>
                    <reports>
                        <report>javadoc</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>

        <plugin> <!-- cobertura report -->
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>cobertura-maven-plugin</artifactId>
            <version>${cobertura.plugin.version}</version>
        </plugin>

        <plugin> <!-- checkstyle report -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
            <version>${checkstyle.plugin.version}</version>
            <configuration>
                <configLocation>${basedir}/checkstyle.xml</configLocation>
                <includeTestSourceDirectory>true</includeTestSourceDirectory>
            </configuration>
        </plugin>

        <plugin> <!-- pmd report -->
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-pmd-plugin</artifactId>
            <version>${pmd.plugin.version}</version>
            <configuration>
                <skipEmptyReport>false</skipEmptyReport>
                <includeTests>true</includeTests>
                <rulesets>
                    <ruleset>pmd-rules.xml</ruleset>
                </rulesets>
            </configuration>
        </plugin>

        <plugin> <!-- findbugs report -->
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>findbugs-maven-plugin</artifactId>
            <version>${findbugs.plugin.version}</version>
            <configuration>
                <xmlOutput>true</xmlOutput>
                <includeTests>true</includeTests>
            </configuration>
        </plugin>
    </plugins>
</reporting>

1 个答案:

答案 0 :(得分:0)

如果您在本地工作区内工作,则可以运行 - 清理编译 - 目标。当您最终完成并推进到更高的环境 - DEV / TEST / pre-prod,那么您将为您的项目运行所有建议的目标。 请查看此链接,了解每个目标的详细信息 -

https://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html