Maven2: How to create a file containing project dependency names?

I would like to put the dependency names in a text file that is distributed inside a package that is built using Maven.

I plan to use the maven build plugin to create the tarball package and use filtering to put the names in a text file.

The only problem: I do not know how to refer to dependencies in the first place.

+3
source share
3 answers

, Maven Dependency dependency:tree, . outputFile. , :

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>tree</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>tree</goal>
            </goals>
            <configuration>
              <outputFile>${project.build.outputDirectory}/dep.txt</outputFile>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  ...
</project>

package target/classes/dep.txt . .

+6

maven-dependency-plugin dependency:tree, .

0

mvn dependency:resolve , , . POM:

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <executions>
      <execution>
        <id>list-dependencies</id>
        <phase>prepare-package</phase>
        <goals>
          <goal>resolve</goal>
        </goals>
        <configuration>
          <outputFile>dependencies.txt</outputFile>
        </configuration>
      </execution>
    </executions>
  </plugin>

dependencies.txt , :

The following files have been resolved:
   am:amagent:jar:1.0:system
   am:amclientsdk:jar:1.0:system
   aopalliance:aopalliance:jar:1.0:compile
   asm:asm:jar:2.2.3:compile
   com.sun.jdmk:jmxtools:jar:1.2.1:compile
   com.sun.jmx:jmxri:jar:1.2.1:compile
   com.sun.xml.bind:jaxb-impl:jar:2.1.12:compile
   com.sun.xml.fastinfoset:FastInfoset:jar:1.2.2:compile
   com.sun.xml.messaging.saaj:saaj-impl:jar:1.3.2:compile
   commons-lang:commons-lang:jar:2.3:compile
   commons-logging:commons-logging:jar:1.1:compile
   dom4j:dom4j:jar:1.6.1:compile
   javax.activation:activation:jar:1.1:provided
   javax.jms:jms:jar:1.1:compile
   javax.mail:mail:jar:1.4:compile
   javax.xml.bind:jaxb-api:jar:2.1:compile
   javax.xml.soap:saaj-api:jar:1.3:compile
   junit:junit:jar:4.4:test
   log4j:log4j:jar:1.2.15:compile
0

Source: https://habr.com/ru/post/1739494/


All Articles