我正在尝试为项目设置这个Maven构建,并希望得到一些帮助以使依赖工作。
Project
|--pom.xml
|--environments
|--pom.xml
|--configuration
|--pom.xml
|--idm
|--pom.xml
|--other
|--pom.xml
|--iam-scripts
|--pom.xml
pom.xml
模块的 idm
如下:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>saas</groupId>
<artifactId>environments</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../environments</relativePath>
</parent>
<groupId>configuration</groupId>
<artifactId>idm</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<configuration>
<filesets>
<fileset>
<directory>${basedir}/modules/iam3/files</directory>
<includes>
<include>iam-scripts.tgz</include>
</includes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-ext-artifacts</id>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>other</groupId>
<artifactId>iam-scripts</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>tar.gz</type>
<overWrite>true</overWrite>
<outputDirectory>${basedir}/modules/iam3/files</outputDirectory>
<destFileName>iam-scripts.tgz</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>${basedir}/modules</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
<include>**/*.conf</include>
<include>**/*.yaml</include>
<include>**/*.varfile</include>
<include>**/*.sh</include>
<include>**/*.html</include>
<include>**/*.tmpl</include>
<include>**/*.tmpl.html</include>
<include>**/*.groovy</include>
<include>**/*.erb</include>
</includes>
</resource>
<resource>
<directory>${basedir}/modules</directory>
<filtering>false</filtering>
<includes>
<include>**/*.sql</include>
<include>**/*.service</include>
<include>**/*.war</include>
<include>**/*.groovy</include>
<include>**/*.gitkeep</include>
<include>**/*.zip</include>
<include>**/*.tar.gz</include>
<include>**/*.tgz</include>
<include>**/*.jar</include>
<include>**/*.pp</include>
<include>**/*.so</include>
<include>**/*.rpm</include>
<include>**/*.erb</include>
</includes>
</resource>
</resources>
</build>
</project>
pom.xml
模块的 iam-scripts
如下:
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>saas</groupId>
<artifactId>environments</artifactId>
<version>1.0.0-SNAPSHOT</version>
<relativePath>../../environments</relativePath>
</parent>
<groupId>other</groupId>
<artifactId>iam-scripts</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>
src/assembly/conf.xml
</descriptor>
</descriptors>
<finalName>${project.artifactId}</finalName>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>${basedir}/src/conf</directory>
<filtering>true</filtering>
<includes>
<include>**/*.xml</include>
<include>**/*.properties</include>
<include>**/*.conf</include>
<include>**/*.yaml</include>
<include>**/*.varfile</include>
<include>**/*.sh</include>
<include>**/*.html</include>
<include>**/*.tmpl</include>
<include>**/*.tmpl.html</include>
<include>**/*.groovy*</include>
<include>**/*.rptdesign</include>
<include>**/*.cps</include>
</includes>
</resource>
<resource>
<directory>${basedir}/src/conf</directory>
<filtering>false</filtering>
<includes>
<include>**/*.sql</include>
<include>**/*.service</include>
<include>**/*.war</include>
<include>**/*.gitkeep</include>
<include>**/*.zip</include>
<include>**/*.tar.gz</include>
<include>**/*.tgz</include>
<include>**/*.jar</include>
<include>**/*.pp</include>
<include>**/*.so</include>
<include>**/*.rpm</include>
<include>**/*.erb</include>
<include>**/*.md</include>
<include>**/*.js</include>
</includes>
</resource>
</resources>
</build>
</project>
所以我需要做的是从idm
模块我需要调用idm-scripts
模块构建。目前(如pom.xml
所示)它只是从存储库中复制iam-scripts.tgz
。但是我说我在iam-scripts
内改变了一些内容,而不是做iam-scripts
的手动干净构建我希望从idm
模块中进行构建。
我现在采取的步骤是:
iam-scripts
内,我mvn clean install -Denv=xxx
idm
内,mvn clean install -Denv=xxx
如何通过idm
构建来调用iam-scripts
的干净版本?
答案 0 :(得分:1)
让我先问一个关于你的POM结构的问题:
什么是......
configuration/pom.xml
和other/pom.xml
......两者兼顾......
idm/pom.xml
和iam-scripts/pom.xml
......让environments/pom.xml
作为他们的父母?无论如何,在构建idm
或iam-scripts
时将其排除在外。 (顺便说一句,我个人认为,通过relativePath
跨多个级别的目录交叉引用项目尚不清楚,我正在避免这样做。)
在我看来,从另一个项目中调用项目不符合POM的声明性质。虽然可能有一个插件我不知道这实现了。 (哦,是的,我知道一个:GMaven [加]。虽然我不推荐它。)
要立即构建idm
和iam-scripts
我会为他们使用通用的pom
打包父POM(也许您的Project
可用于此)并添加它们在<module>
中。{/ p>
见