Netbeans和Maven,使用相关项目进行清理和构建 [英] Netbeans and Maven, Clean and Build with dependent projects

查看:104
本文介绍了Netbeans和Maven,使用相关项目进行清理和构建的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Netbeans中有一个Maven项目,该项目依赖于其他Maven项目, 当我执行清理并仅构建当前正在清理和构建的项目时-我可以以某种方式使netbeans清理并生成每个相关项目吗?

I have a maven project in Netbeans which depend on other maven projects, when i perform clean and build only the current project getting clean and build - can i somehow make netbeans perform clean and build for every dependent project?

我经常需要执行清理和构建的原因是因为某些原因,netbeans不在常规构建上执行注释处理,并且当我更改注释处理器时,我需要所有项目都必须进行清理和构建...

the reason that i often need to perform clean and build is because for some reason netbeans does not execute annotation processing on regular build and when i change my annotation processor i need that all my projects will get clean and build...

推荐答案

当您有一些依赖于许多相关项目的核心项目时,这是常见的要求.因此,您想先构建所有依赖项目,然后再构建核心项目并将其打包.

This is a common requirement when you have some core project depending on many dependent projects. So, you would like to first build all the dependent projects and then the core project and package it.

通常,这是使用某些Aggreator项目完成的,该项目仅包含一个pom.xml文件,该文件将调用所有其他项目的pom.以下是示例pom文件之一,它将满足您的目的.

Normally this is done using some Aggreator-project which will just contain a pom.xml file which will invoke the pom of all other projects. Below is one of the sample pom file which will server your purpose.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>BuildAggregator</groupId>
    <artifactId>BuildAggregator</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>
    <name>aggregator Project</name>
    <description>All module aggregator Project</description>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <showWarnings>true</showWarnings>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <modules>
        <module>../DependentProject1-jar</module>
        <module>../CoreProject-jar</module>
    </modules>
</project>

注意模块部分,您只需要使用pom项目名称进行更改即可.

Notice the module section, you just have to change it with your pom project names.

因此,这将使事情变得非常方便.那就是每当您要构建所有项目时,您只需要运行此BuildAggregator项目,它将执行所有构建和打包任务(假设独立pom没有任何问题,因为这会导致构建失败并且会在控制台中显示原因.)

So, this will make things very handy. That is whenever you want to build all the project you just have to run this BuildAggregator project and it will do all the build and packaging task (assuming your standalone pom doesn't have any issue, as it will cause build fail and will show you the reason in console.)

这篇关于Netbeans和Maven,使用相关项目进行清理和构建的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆