我有一个多模块maven项目。对于这个例子,我们考虑它们的两个模块:
在父pom的dependencyManagement部分有Saxon库。我所有的pom和.m2文件夹中这个依赖项的确切名称是" saxon-he"。 但是最近这个lib已经在远程存储库中重命名为" Saxon-HE"。
当我尝试在maven控制台(mvn help:effective-pom)中为子模块生成有效pom时,我收到错误
[ERROR]' dependencies.dependency.version'对于 net.sf.saxon:saxon-he:jar丢失。
据我所知,这个错误是lib名称差异的自然结果 但更感兴趣的是:当我尝试在IntelliJ IDEA中为子模块生成有效pom时,我正确地形成了有效的pom,但Saxon依赖的名称就像在远程存储库中一样 - "撒克逊-HE&#34 ;.我在本地计算机上的任何文本文件中都没有这么精确的字符串。
所以,我的问题是IntelliJ IDEA与捆绑的maven 3的名称和#34; Saxon-HE"?
以下是我的poms:
父pom
<?xml version="1.0" encoding="UTF-8"?>
<project 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.project</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPHOT</version>
<packaging>pom</packaging>
<prerequisites>
<maven>2.2.1</maven>
</prerequisites>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>saxon-he</artifactId>
<version>9.7.0-7</version>
<scope>provided</scope>
</dependency>
//Other external dependencies. No dependencies onto other modules of the project.
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerVersion>1.8</compilerVersion>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<profiles>
<profile>
<id>all</id>
<modules>
<module>../CHILD_DIRECTORY</module>
//Other child modules
</modules>
</profile>
//Other profiles
</profiles>
<distributionManagement>
<repository>
<id>internal</id>
<name>Internal Release Repository</name>
<url>URL_TO_RELEASE_REPO</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshot Repository</name>
<url>URL_TO_SNAPSHOT_REPO</url>
</snapshotRepository>
</distributionManagement>
</project>
child pom
<?xml version="1.0" encoding="UTF-8"?>
<project 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>com.project</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPHOT</version>
</parent>
<groupId>com.project</groupId>
<artifactId>child</artifactId>
<packaging>pom</packaging>
<modules>
//Child modules of this module
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<versionRange>
[2.1,)
</versionRange>
<goals>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-antrun-plugin
</artifactId>
<versionRange>
[1.3,)
</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.codehaus.mojo
</groupId>
<artifactId>
exec-maven-plugin
</artifactId>
<versionRange>
[1.1,)
</versionRange>
<goals>
<goal>java</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.jvnet.jaxb2.maven2
</groupId>
<artifactId>
maven-jaxb2-plugin
</artifactId>
<versionRange>
[0.7.4,)
</versionRange>
<goals>
<goal>generate</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
//There is no Saxon dependency here. It is in <dependencyManagement> section of parent module (with version)
//and in child modules of this module in <dependencies> section (without version)
</dependencies>
<distributionManagement>
<repository>
<id>internal</id>
<name>Internal Release Repository</name>
<url>${build.release.url}</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshot Repository</name>
<url>${build.snapshot.url}</url>
</snapshotRepository>
</distributionManagement>
</project>
.m2文件夹中的settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<username>UNAME</username>
<password>PASS</password>
<id>central</id>
</server>
<server>
<username>UNAME</username>
<password>PASS</password>
<id>snapshots</id>
</server>
</servers>
<profiles>
<profile>
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>URL_TO_RELEASE_REPO</url>
</repository>
<repository>
<snapshots />
<id>snapshots</id>
<name>libs-snapshot</name>
<url>URL_TO_SNAPSHOT_REPO</url>
</repository>
<repository>
<snapshots />
<id>repo1-cache</id>
<name>repo1-cache</name>
<url>URL_TO_REPO_CACHE</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>URL_TO_PLUGINS_RELEASE_REPO</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>URL_TO_PLUGINS_SNAPSHOT_REPO</url>
</pluginRepository>
<pluginRepository>
<snapshots />
<id>repo1-cache</id>
<name>repo1-cache</name>
<url>URL_TO_REPO_CACHE</url>
</pluginRepository>
</pluginRepositories>
<id>artifactory</id>
</profile>
</profiles>
<activeProfiles>
<activeProfile>artifactory</activeProfile>
</activeProfiles>
</settings>
由子模块的IntelliJ effective-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>
<parent>
<groupId>com.project</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.project</groupId>
<artifactId>child</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
//Child modules of this module
</modules>
<distributionManagement>
<repository>
<id>internal</id>
<name>Internal Release Repository</name>
<url>${build.release.url}</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Internal Snapshot Repository</name>
<url>${build.snapshot.url}</url>
</snapshotRepository>
</distributionManagement>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<version>9.7.0-7</version>
<scope>provided</scope>
</dependency>
//Other external dependencies. No dependencies onto other modules of the project.
</dependencies>
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>central</id>
<name>libs-release</name>
<url>URL_TO_RELEASE_REPO</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>snapshots</id>
<name>libs-snapshot</name>
<url>URL_TO_SNAPSHOT_REPO</url>
</repository>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>repo1-cache</id>
<name>repo1-cache</name>
<url>URL_TO_REPO_CACHE</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>central</id>
<name>plugins-release</name>
<url>URL_TO_PLUGINS_RELEASE_REPO</url>
</pluginRepository>
<pluginRepository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>snapshots</id>
<name>plugins-snapshot</name>
<url>URL_TO_PLUGINS_SNAPSHOT_REPO</url>
</pluginRepository>
<pluginRepository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>repo1-cache</id>
<name>repo1-cache</name>
<url>URL_TO_REPO_CACHE</url>
</pluginRepository>
</pluginRepositories>
<build>
<sourceDirectory>CHILD_SRC_DIRECTORY</sourceDirectory>
<scriptSourceDirectory>CHILD_SCRIPT_SRC_DIRECTORY</scriptSourceDirectory>
<testSourceDirectory>CHILD_TEST_SRC_DIRECTORY</testSourceDirectory>
<outputDirectory>CHILD_TARGET_DIRECTORY</outputDirectory>
<testOutputDirectory>CHILD_TEST_TARGET_DIRECTORY</testOutputDirectory>
<resources>
<resource>
<directory>CHILD_RESOURCES_DIRECTORY</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>CHILD_TEST_RESOURCES_DIRECTORY</directory>
</testResource>
</testResources>
<directory>CHILD_TARGET_DIRECTORY</directory>
<finalName>FINAL_NAME</finalName>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
</plugin>
<plugin>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerVersion>1.8</compilerVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[2.1,)</versionRange>
<goals>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<versionRange>[1.3,)</versionRange>
<goals>
<goal>run</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<versionRange>[1.1,)</versionRange>
<goals>
<goal>java</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<versionRange>[0.7.4,)</versionRange>
<goals>
<goal>generate</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerVersion>1.8</compilerVersion>
</configuration>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>default-clean</id>
<phase>clean</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default-install</id>
<phase>install</phase>
<goals>
<goal>install</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<executions>
<execution>
<id>default-site</id>
<phase>site</phase>
<goals>
<goal>site</goal>
</goals>
<configuration>
<outputDirectory>CHILD_SITE_DIRECTORY</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
<execution>
<id>default-deploy</id>
<phase>site-deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
<configuration>
<outputDirectory>CHILD_SITE_DIRECTORY</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</execution>
</executions>
<configuration>
<outputDirectory>CHILD_SITE_DIRECTORY</outputDirectory>
<reportPlugins>
<reportPlugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
</reportPlugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
<reporting>
<outputDirectory>CHILD_SITE_DIRECTORY</outputDirectory>
</reporting>
</project>