Каким будет groupId для зависимостей, используемых внутри pom, если в свойствах не указана переменная? - PullRequest
0 голосов
/ 05 ноября 2018

Пом, что я смотрю в это:

<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>
  <groupId>org.apache.felix</groupId>
  <artifactId>felix-parent</artifactId>
  <version>1.2.0</version>
  <relativePath>../pom/pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>bundle</packaging>
<name>Apache Felix Main</name>
<artifactId>org.apache.felix.main</artifactId>
<version>2.0.2</version>
<dependencies>
  <dependency>
    <groupId>${pom.groupId}</groupId>
    <artifactId>org.apache.felix.framework</artifactId>
    <version>2.0.2</version>
    <exclusions>
      <exclusion>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
      </exclusion>
      <exclusion>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.compendium</artifactId>
      </exclusion>
    </exclusions>
  </dependency>
  <dependency>
    <groupId>${pom.groupId}</groupId>
    <artifactId>org.apache.felix.shell</artifactId>
    <version>1.4.1</version>
    <exclusions>
      <exclusion>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
      </exclusion>
      <exclusion>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.compendium</artifactId>
      </exclusion>
    </exclusions>
  </dependency>
  <dependency>
    <groupId>${pom.groupId}</groupId>
    <artifactId>org.apache.felix.shell.tui</artifactId>
    <version>1.4.1</version>
    <exclusions>
      <exclusion>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
      </exclusion>
      <exclusion>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.compendium</artifactId>
      </exclusion>
    </exclusions>
  </dependency>
  <dependency>
    <groupId>${pom.groupId}</groupId>
    <artifactId>org.apache.felix.bundlerepository</artifactId>
    <version>1.4.2</version>
    <exclusions>
      <exclusion>
        <groupId>${pom.groupId}</groupId>
        <artifactId>org.osgi.core</artifactId>
      </exclusion>
      <exclusion>
        <groupId>${pom.groupId}</groupId>
        <artifactId>org.osgi.compendium</artifactId>
      </exclusion>
      <exclusion>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.core</artifactId>
      </exclusion>
      <exclusion>
        <groupId>org.osgi</groupId>
        <artifactId>org.osgi.compendium</artifactId>
      </exclusion>
      <exclusion>
        <groupId>${pom.groupId}</groupId>
        <artifactId>org.osgi.service.obr</artifactId>
      </exclusion>
      <exclusion>
        <groupId>net.sf.kxml</groupId>
        <artifactId>kxml2</artifactId>
      </exclusion>
    </exclusions>
  </dependency>
</dependencies>
<properties>
  <log.level>1</log.level>
  <dollar>$</dollar>
</properties>
<profiles>
  <profile>
    <id>release</id>
    <properties>
      <log.level>1</log.level>
      <dollar>$</dollar>
    </properties>
  </profile>
</profiles>
<build>
  <plugins>
    <plugin>
      <groupId>org.apache.felix</groupId>
      <artifactId>maven-bundle-plugin</artifactId>
      <version>1.4.3</version>
      <extensions>true</extensions>
      <configuration>
        <instructions>
          <_donotcopy>(CVS|.svn|config.properties)</_donotcopy>
          <Main-Class>org.apache.felix.main.Main</Main-Class>
          <Bundle-SymbolicName>org.apache.felix.main</Bundle-SymbolicName>
          <Bundle-Name>Apache Felix</Bundle-Name>
          <Bundle-Description>OSGi R4 framework.</Bundle-Description>
          <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
          <Embed-Dependency>*;artifactId=org.apache.felix.framework;inline=true</Embed-Dependency>
          <Private-Package>org.apache.felix.main.*</Private-Package>
          <Export-Package>!org.osgi.service.log, !org.osgi.service.obr,org.osgi.*</Export-Package>
          <Import-Package>!*</Import-Package>
          <Include-Resource>META-INF/LICENSE=LICENSE,META-INF/NOTICE=NOTICE,{src/main/resources/}</Include-Resource>
        </instructions>
      </configuration>
    </plugin>
    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>rat-maven-plugin</artifactId>
      <configuration>
        <excludeSubProjects>false</excludeSubProjects>
        <useEclipseDefaultExcludes>true</useEclipseDefaultExcludes>
        <useMavenDefaultExcludes>true</useMavenDefaultExcludes>
        <excludes>
          <param>doc/*</param>
          <param>maven-eclipse.xml</param>
          <param>.checkstyle</param>
          <param>.externalToolBuilders/*</param>
        </excludes>
      </configuration>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-dependency-plugin</artifactId>
      <executions>
        <execution>
          <id>unpack</id>
          <phase>validate</phase>
          <goals>
            <goal>unpack</goal>
          </goals>
          <configuration>
             <outputDirectory>${project.build.outputDirectory}</outputDirectory>
            <artifactItems>
              <artifactItem>
                <groupId>${pom.groupId}</groupId>
                <artifactId>org.apache.felix.framework</artifactId>
                <version>2.0.2</version>
              </artifactItem>
            </artifactItems>
          </configuration>
        </execution>
        <execution>
          <id>copy</id>
          <phase>install</phase>
          <goals>
            <goal>copy</goal>
          </goals>
          <configuration>
              <artifactItems>
                <artifactItem>
                   <groupId>${pom.groupId}</groupId>
                   <artifactId>org.apache.felix.shell</artifactId>
                   <version>1.4.1</version>
                   <type>jar</type>
                   <overWrite>true</overWrite>
                   <outputDirectory>${project.build.directory}/bundle</outputDirectory>
                 </artifactItem>
                 <artifactItem>
                   <groupId>${pom.groupId}</groupId>
                   <artifactId>org.apache.felix.shell.tui</artifactId>
                   <version>1.4.1</version>
                   <type>jar</type>
                   <overWrite>true</overWrite>
                   <outputDirectory>${project.build.directory}/bundle</outputDirectory>
                 </artifactItem>
                 <artifactItem>
                   <groupId>${pom.groupId}</groupId>
                   <artifactId>org.apache.felix.bundlerepository</artifactId>
                   <version>1.4.2</version>
                   <type>jar</type>
                   <overWrite>true</overWrite>
                   <outputDirectory>${project.build.directory}/bundle</outputDirectory>
                 </artifactItem>
               </artifactItems>
          </configuration>
        </execution>
      </executions>
    </plugin>
    <plugin>
      <artifactId>maven-antrun-plugin</artifactId>
      <executions>
        <execution>
          <phase>install</phase>
          <configuration>
            <tasks>
              <delete dir="${basedir}/bin" />
              <mkdir dir="${basedir}/bin" />
              <delete dir="${basedir}/conf" />
              <mkdir dir="${basedir}/conf" />
              <delete dir="${basedir}/bundle" />
              <copy file="${basedir}/target/org.apache.felix.main-${pom.version}.jar" tofile="${basedir}/bin/felix.jar" />
              <copy file="${basedir}/target/classes/config.properties" todir="${basedir}/conf" />
              <move file="${basedir}/target/bundle" todir="${basedir}" />
            </tasks>
          </configuration>
          <goals>
            <goal>run</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
  <resources>
    <resource>
      <directory>src/main/resources</directory>
      <filtering>true</filtering>
    </resource>
  </resources> 
</build>

<scm>
  <connection>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.main-2.0.2</connection>
  <developerConnection>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.main-2.0.2</developerConnection>
  <url>scm:svn:https://svn.apache.org/repos/asf/felix/releases/org.apache.felix.main-2.0.2</url>
</scm>
</project>

Я не могу понять, что именно groupId будет использоваться везде, где $ {pom.groupId} указан в используемых зависимостях. Я посмотрел в родительском pom и не смог найти там никаких переменных, определенных с именем pom.groupId. Так откуда будет взята группа?

Единственное предположение, которое я могу сделать, это то, что он должен использовать groupId самого pom, но его там тоже нет, присутствуют только теги artifactId и version.
Примечание. Я получаю pom с помощью информации GAV, поэтому у меня есть groupId, но я уверен, что должен быть более конкретный или какой-то другой способ определения groupId из самого pom.

Еще один экземпляр pom, где это было сделано (3-я зависимость), но здесь присутствует тег groupId, но нет $ {version}:
Каковы будут значения $ {groupId} и $ {version} здесь? (У родителей этого помета тоже нет переменных с таким именем)

<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>org.hibernate</groupId>
        <artifactId>hibernate-parent</artifactId>
        <version>3.5.0-Final</version>
        <relativePath>../parent/pom.xml</relativePath>
    </parent>

    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-annotations</artifactId>
    <packaging>jar</packaging>

    <name>Hibernate Annotations</name>
    <description>Annotations metadata for Hibernate</description>

    <dependencies>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>${version}</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-commons-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>org.hibernate.javax.persistence</groupId>
            <artifactId>hibernate-jpa-2.0-api</artifactId>
        </dependency>
        <dependency>
            <groupId>${groupId}</groupId>
            <artifactId>hibernate-testing</artifactId>
            <version>${version}</version>
            <scope>test</scope>
        </dependency>      
        <dependency>
            <groupId>javassist</groupId>
            <artifactId>javassist</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <testResources>
            <testResource>
                <filtering>false</filtering>
                <directory>src/test/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </testResource>
            <testResource>
                <filtering>true</filtering>
                <directory>src/test/resources</directory>
            </testResource>
        </testResources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.5</source>
                    <target>1.5</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jboss.maven.plugins</groupId>
                <artifactId>maven-test-ext-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.jboss.maven.plugins</groupId>
                <artifactId>maven-injection-plugin</artifactId>
                <configuration>
                    <bytecodeInjections>
                        <bytecodeInjection>
                            <expression>${pom.version}</expression>
                            <targetMembers>
                              <methodBodyReturn>
                                  <className>org.hibernate.cfg.annotations.Version</className>
                                  <methodName>getVersionString</methodName>
                              </methodBodyReturn>
                            </targetMembers>
                        </bytecodeInjection>
                    </bytecodeInjections>
                </configuration>
            </plugin>            
            <plugin>
                <groupId>org.twdata.maven</groupId>
                <artifactId>maven-cli-plugin</artifactId>
                <version>0.6.4</version>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>jaxb</id>
            <activation>
                <jdk>1.5</jdk>
            </activation>
            <dependencies>
                <dependency>
                    <groupId>javax.xml.bind</groupId>
                    <artifactId>jaxb-api</artifactId>
                    <version>2.1</version>
                    <scope>test</scope>
                </dependency>
                <dependency>
                    <groupId>com.sun.xml.bind</groupId>
                    <artifactId>jaxb-impl</artifactId>
                    <version>2.1.3</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>doc</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jboss.maven.plugins</groupId>
                        <artifactId>maven-jdocbook-plugin</artifactId>
                        <configuration>
                            <sourceDocumentName>master.xml</sourceDocumentName>
                            <sourceDirectory>${basedir}/src/main/docbook</sourceDirectory>
                            <masterTranslation>en</masterTranslation>
                            <imageResource>
                                <directory>${basedir}/src/main/docbook/en/images</directory>
                            </imageResource>
                        </configuration>
                        <executions>
                            <execution>
                                <id>make-doc</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>resources</goal>
                                    <goal>generate</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
...