3

I have a multi-module maven project. For this example let's consider two modules of them:

  1. parent module (pom packaging);
  2. child module (also pom packaging).

There is Saxon library in dependencyManagement section of the parent pom. The exact name of this dependency in all my pom's and in .m2 folder is "saxon-he". But recently this lib has been renamed in remote repository to "Saxon-HE".

When I try to generate effective-pom for child module in maven console (mvn help:effective-pom), I'm getting an error

[ERROR] 'dependencies.dependency.version' for net.sf.saxon:saxon-he:jar is missing.

I understand that this error is the natural consequence of lib name discrepancy.
But more interest is other: when I try to generate effective-pom for child module in IntelliJ IDEA, I'm getting correctly formed effective-pom, but the name of Saxon dependency is like in the remote repository - "Saxon-HE". I don't have such exact string in any text file on my local machine.

So, my question is from where IntelliJ IDEA with bundled maven 3 gets the name "Saxon-HE"?

Below are my poms:

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

settings.xml in .m2 folder

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

generated by IntelliJ effective-pom for child module

<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>
Roman Khomyshynets
  • 724
  • 1
  • 9
  • 12
  • How? Programmatically: https://github.com/JetBrains/intellij-community/blob/master/plugins/maven/maven3-server-common/src/org/jetbrains/idea/maven/server/MavenEffectivePomDumper.java Why is it different? Who knows. – Meo Mar 19 '18 at 22:34

0 Answers0