强制maven在插件执行后不重建子模块

时间:2018-07-27 09:25:50

标签: java maven

我有一个由7个项目组成的Maven多模块项目

父Pom

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>dag-app.dag</groupId>
    <artifactId>dag-app</artifactId>
    <version>3.0.0.RELEASE</version>
    <packaging>pom</packaging>
    <name>dag Parent application (pom)</name>
    <description>dag parent pom application</description>

    <properties>
        <maven.resources.overwrite>true</maven.resources.overwrite>
        <project.build.sourceEncdagng>UTF-8</project.build.sourceEncdagng>
        <!-- temporarly disable tests -->
        <maven.test.skip>true</maven.test.skip>
        <argLine>-noverify</argLine>
        <!-- other dependencies -->
    </properties>


    <dependencyManagement>
    <dependencies>
        <!-- business project dependency -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>dag-business</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <!-- db repository project dependency -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>dag-db-repository</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <!--  db model project dependency -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>dag-db-model</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <!-- es repository dependency -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>dag-es-repository</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <!-- es model dependency -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>dag-es-model</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <!-- common dependency -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>dag-common</artifactId>
            <version>${project.parent.version}</version>
        </dependency>
        <!-- other dependencies -->
    </dependencyManagement>

    <build>
        <finalName>${project.artifactId}-${project.version}</finalName>
        <pluginManagement>
            <plugins>
                <!-- compiler plugin -->
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>


    <modules>
        <module>../dag-common</module>
        <module>../dag-es-model</module>
        <module>../dag-db-model</module>
        <module>../dag-es-repository</module>   
        <module>../dag-db-repository</module>
        <module>../dag-business</module>
        <module>../dag-rest</module>
    </modules>

    <!-- private application repository -->
    <repositories>
        <repository>
            <id>privateRepo</id>
            <name>privateRepo</name>
            <releases>
                <enabled>true</enabled>
                <checksumPolicy>ignore</checksumPolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <url>http://rnexus.intra.dag.fr/rnexus/content/repositories/dag-projects/</url>
        </repository>

        <!-- local repo -->
        <repository>
            <id>localrepository</id>
            <url>file://D:/Public/Dev/Repo/</url>
            <snapshots>
                <enabled>true</enabled>
                <checksumPolicy>fail</checksumPolicy>
            </snapshots>
        </repository> 
    </repositories>
</project>

该应用程序可以使用Jenkins在本地正确编译和构建

[INFO] Reactor Summary:
[INFO] 
[INFO] dag Parent application (pom) ....................... SUCCESS [  2.657 s]
[INFO] dag-common ......................................... SUCCESS [  8.635 s]
[INFO] dag-es-model ....................................... SUCCESS [  1.871 s]
[INFO] dag-db-model ....................................... SUCCESS [  0.883 s]
[INFO] dag-es-repository .................................. SUCCESS [  9.465 s]
[INFO] dag-db-repository .................................. SUCCESS [ 12.457 s]
[INFO] dag-business ....................................... SUCCESS [  6.288 s]
[INFO] dag-rest ........................................... SUCCESS [ 31.430 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:14 min
[INFO] Finished at: 2018-07-27T10:33:28+02:00
[INFO] Final Memory: 47M/116M
[INFO] ------------------------------------------------------------------------

但是在构建之后,我们有一个liquibase(mvn liquibase:update)任务失败

Entering stage LiquiBase Migration
Proceeding
[Pipeline] node
Running on Agent-s0066tts in /logiciel/work/f34668da/workspace/dag-65454/dag Performance
[Pipeline] {
[Pipeline] withCredentials
[Pipeline] {
[Pipeline] tool
[Pipeline] sh
[dag Performance] Running shell script
+ cd dag-db-repository
+ /logiciel/jenkins/apache-maven-3.3.9/bin/mvn liquibase:update
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building dag-db-repository 3.0.0.RELEASE
[INFO] ------------------------------------------------------------------------
Downloading: http://rnexus.intra.dag.fr/rnexus/content/groups/dag-entry/dag-app/dag/dag-db-model/3.0.0.RELEASE/dag-db-model-3.0.0.RELEASE.pom

Downloading: http://rnexus.intra.dag.fr/rnexus/content/repositories/releases/dag-app/dag/dag-db-model/3.0.0.RELEASE/dag-db-model-3.0.0.RELEASE.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.102 s
[INFO] Finished at: 2018-07-27T10:33:35+02:00
[INFO] Final Memory: 10M/60M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project dag-db-repository: Could not resolve dependencies for project dag-app.dag:dag-db-repository:jar:3.0.0.RELEASE: Could not find artifact dag-app.dag:dag-db-model:jar:3.0.0.RELEASE in dagMirror (http://rnexus.intra.dag.fr/rnexus/content/groups/dag-entry/) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

db-repository的pom具有db-model作为依赖项

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <!-- parent -->
    <parent>
        <groupId>dag-app.dag</groupId>
        <artifactId>dag-app</artifactId>
        <version>3.0.0.RELEASE</version>
        <relativePath>../dag-app</relativePath>
    </parent>

    <!-- current module -->
    <name>dag-db-repository</name>
    <description>database layer of the application(data-access-object)</description>
    <artifactId>dag-db-repository</artifactId>
    <packaging>jar</packaging>

    <dependencies>
        <!-- db model dependency -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>dag-db-model</artifactId>
        </dependency>
        <!-- other dependencies -->
    </dependencies>

    <!-- build plugin -->
    <build>
        <!-- compiler plugin inherited from parent -->
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerArguments>
                        <processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
                    </compilerArguments>
                </configuration>
            </plugin>

            <!-- liquibase migration DB plugin -->
            <!-- problem is here -->
            <plugin>
                <groupId>org.liquibase</groupId>
                <artifactId>liquibase-maven-plugin</artifactId>
                <version>3.0.5</version>
                <configuration>
                    <propertyFile>src/main/resources/liquibase/liquibase.properties</propertyFile>
                     <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>update</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

您可以看到执行liquibase-maven-plugin时失败
我不明白为什么Maven在执行此插件时会尝试重建项目,因为它只是更新数据库脚本

它失败了,因为它尝试构建单个模块,因此显然找不到dag-db-model模块并尝试从远程下载

我可以通过从本地存储库中删除dab-db-model并在mvn liquibase:update模块上执行mvn全新安装或dab-db-repository来在本地重现此错误

在执行liquibase任务时如何避免重建dab-db-repository模块或至少不重新下载依赖项(因为应用程序的完整构建已经可以了)

非常感谢您

0 个答案:

没有答案