【问题标题】:Maven release plugin maven 2Maven 发布插件 Maven 2
【发布时间】:2012-09-19 10:02:00
【问题描述】:

我有一个多模块项目,例如父 pom 上定义的模块,例如:

<modules>
    <module>child1</module>
    <module>child2</module>
</modules>

当我在父项目mvn release:prepare 上键入时,它会构建每个子项目,并最终构建自身。有没有办法告诉发布插件安装每个孩子?所以当我输入mvn release:prepare时foreach child: build install,最后发布?

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

<groupId>com.voncuver</groupId>
<artifactId>cu</artifactId>
<packaging>pom</packaging>
<version>1.6.1-SNAPSHOT</version>

<properties>
    <spring-version>2.5.6</spring-version>
    <maven-plugin-version>4.1.0.1-fuse</maven-plugin-version>
</properties>

<scm>
    <connection>scm:svn:file:///C:/Users/voncuver/Documents/myRepository/cu</connection>
    <developerConnection>scm:svn:file:///C:/Users/voncuver/Documents/myRepository/cu</developerConnection>
</scm>

<modules>
    <module>cu-pars-engine</module>
    <module>cu-agent</module>
</modules>


<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
        </resource>
    </resources>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
                <execution>
                    <configuration>
                        <classifier>${target.env}</classifier>
                    </configuration>
                </execution>
            </executions>
            <configuration>
                <archive>
                    <manifest>
                        <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                    </manifest>
                    <manifestEntries>
                        <Build>${JOB_NAME} #${BUILD_NUMBER} at ${BUILD_ID}</Build>
                        <Environment>${environment.type}</Environment>
                        <Revision>${SVN_REVISION}</Revision>
                    </manifestEntries>
                </archive>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-eclipse-plugin</artifactId>
            <version>2.8</version>
        </plugin>
    </plugins>
</build>

<repositories>
    <repository>
        <id>releases</id>
        <url>
            http://maven.vonc.com/content/repositories/releases/
        </url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>snapshots</id>
        <url>
            http://maven.von.com/content/repositories/snapshots/
        </url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

<dependencyManagement>
    <dependencies>
        <dependency>
            <artifactId>cu-pars-engine</artifactId>
            <groupId>com.voncuver</groupId>
            <version>${pom.version}</version>
        </dependency>
        <dependency>
            <artifactId>cu-agent</artifactId>
            <groupId>com.voncuver</groupId>
            <version>${pom.version}</version>
        </dependency>
</dependencyManagement>

<distributionManagement>
    <repository>
        <id>releases</id>
        <url>http://maven.von.com/content/repositories/releases</url>
        <layout>default</layout>
    </repository>
    <snapshotRepository>
        <id>snapshots</id>
        <url>http://maven.von.com/content/repositories/snapshots</url>
        <layout>default</layout>
        <uniqueVersion>true</uniqueVersion>
    </snapshotRepository>
</distributionManagement>

孩子:

<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>

<parent>
    <artifactId>cu</artifactId>
    <groupId>com.voncuver</groupId>
    <version>1.6.1-SNAPSHOT</version>
</parent>

<artifactId>cu-pars-engine</artifactId>
<packaging>jar</packaging>


<dependencies>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.15</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>javacc-maven-plugin</artifactId>
            <version>2.5</version>
            <executions>
                <execution>
                    <id>javacc</id>
                    <goals>
                        <goal>javacc</goal>
                    </goals>
                </execution>
                <execution>
                    <id>javacc-ptparser</id>
                    <goals>
                        <goal>jjtree-javacc</goal>
                    </goals>
                    <configuration>
                        <isStatic>false</isStatic>
                        <buildNodeFiles>true</buildNodeFiles>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

第二个孩子:

<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">
<parent>
    <artifactId>cu</artifactId>
    <groupId>com.voncuver</groupId>
    <version>1.6.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>cu-agent</artifactId>
<packaging>jbi-service-unit</packaging>

<dependencies>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.12</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

【问题讨论】:

  • 您在 child 2 中定义了什么样的包装(是否存在合适的 maven 插件?)。啊找到了(camel.apache.org/jbi.html)。
  • 你项目的文件夹结构如何?
  • 你能在 mvn release:prepare 期间发布完整的错误输出吗?

标签: maven-2 maven-release-plugin


【解决方案1】:

如果你有一个多模块构建,你需要在你的多模块构建的根目录上执行 mvn release:prepare 和 mvn release:perform 步骤,而不是在每个孩子上。

【讨论】:

  • 是的,这是正确的,但就我而言,当我这样做时,mvn release:prepare 会结束失败,因为父项目想要发布的子项目。 Witch 不在本地仓库或远程仓库中。当您执行 mvn release:prepar 时,mvn 会构建每个项目(父、子),但不会安装它。因此,当父项目或子项目依赖于另一个子项目时,它找不到它。我的解决方案是执行 mvn release:prepare 时的额外目标。 link
  • 听起来您的项目配置不正确。你能展示你的根的 pom 和你孩子的一些摘录吗?
  • 我已附加到主帖。谢谢。
猜你喜欢
  • 2020-05-07
  • 2013-01-16
  • 2012-10-14
  • 2014-09-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-15
相关资源
最近更新 更多