maven程序集忽略父依赖项

时间:2009-06-23 18:37:09

标签: maven maven-2 maven-assembly-plugin

我的程序集描述符在依赖项直接包含在pom文件中时正确应用包含和排除。

但是,当我将依赖项放在父pom文件中时,程序集:目录目标报告尚未触发包含和排除。

你知道为什么maven-assembly-plugin会忽略父依赖吗?我该如何解决?

以下是maven和汇编描述符:

装配描述符:

<assembly>
  <id>distribution</id>
  <formats>
    <format>zip</format>
  </formats>
  <fileSets>
    <fileSet>
      <includes>
        <include>readme.txt</include>
      </includes>
    </fileSet>
    <fileSet>
      <directory>target</directory>
      <outputDirectory>/lib</outputDirectory>
      <includes>
        <include>*.jar</include>
      </includes>
    </fileSet>
  </fileSets>
  <dependencySets>
    <dependencySet>
      <outputDirectory>/lib</outputDirectory>
      <unpack>false</unpack>
      <scope>runtime</scope>
      <excludes>
        <exclude>org.tanukisoftware:wrapper:exe:3.3.5</exclude>
      </excludes>
    </dependencySet>
    <dependencySet>
      <outputDirectory>/bin</outputDirectory>
      <unpack>false</unpack>
      <scope>runtime</scope>
      <includes>
        <include>org.tanukisoftware:wrapper:exe:3.3.5</include>
      </includes>
    </dependencySet>
  </dependencySets>
</assembly>

子POM程序集插件定义:

    <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
            <ignoreDirFormatExtensions>true</ignoreDirFormatExtensions>
            <descriptors>
                <descriptor>assembly.xml</descriptor>
            </descriptors>
        </configuration>
        <executions>
            <execution>
                <id>make-assembly</id>
                <phase>package</phase>      
                <goals>
                    <goal>directory</goal>
                </goals>
            </execution>
        </executions>
    </plugin>

父POM依赖关系:

<dependencies>
    <dependency>
        <groupId>org.tanukisoftware</groupId>
        <artifactId>wrapper</artifactId>
        <version>3.3.5</version>
        <type>dll</type>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.tanukisoftware</groupId>
        <artifactId>wrapper</artifactId>
        <version>3.3.5</version>
        <type>exe</type>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.tanukisoftware</groupId>
        <artifactId>wrapper</artifactId>
        <version>3.3.5</version>
        <scope>runtime</scope>
    </dependency>
</dependencies>

构建报告中的警告:

[assembly:directory {execution: make-assembly}]
Reading assembly descriptor: assembly.xml
Processing DependencySet (output=/lib)
[WARNING] The following patterns were never triggered in this artifact exclusion filter:
o  'org.tanukisoftware:wrapper:exe:3.3.5'

Processing DependencySet (output=/bin)
[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o  'org.tanukisoftware:wrapper:exe:3.3.5'

1 个答案:

答案 0 :(得分:6)

我不知道这是否会有所帮助,但我总是在父母的pom中将依赖项放在dependencyManagement块中;

    <dependencyManagement>
    <!-- dependencies with exclusions -->
    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>

            <version>${version.springframework}</version>

            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

然后,在子pom中,再次列出依赖项,但没有版本和排除

  <dependencies>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-aop</artifactId>
    </dependency>

但说实话,对于我的第一个也是唯一一个组装,我无法让它在子模块中工作并将其放在父母的pom中。这是我的汇编文件,用于为独立的java程序创建一个zip文件,由cron运行:

<?xml version="1.0" encoding="UTF-8"?>

<assembly>
  <id>${project.layer}-both</id>

  <formats>
      <format>zip</format>
  </formats>

  <includeBaseDirectory>false</includeBaseDirectory>

  <baseDirectory>/</baseDirectory>

  <moduleSets>
      <moduleSet>
          <includes>
              <include>edu.berkeley.ist.cars:cars_upload</include>
          </includes>

          <binaries>
              <unpack>false</unpack>
              <useStrictFiltering>true</useStrictFiltering>
              <includeDependencies>true</includeDependencies>
              <outputDirectory>upload</outputDirectory>
          </binaries>
      </moduleSet>

      <moduleSet>
          <includes>
              <include>edu.berkeley.ist.cars:cars_download</include>
          </includes>

          <binaries>
              <unpack>false</unpack>
              <useStrictFiltering>true</useStrictFiltering>
              <includeDependencies>true</includeDependencies>
              <outputDirectory>download</outputDirectory>
          </binaries>
      </moduleSet>
  </moduleSets>

  <!--
      crontab.txt is put in twice, in both upload and download, just in case.
      -->
  <files>
      <!-- upload files -->
      <file>
          <source>src/stuff/scripts/cars_upload.sh</source>
          <lineEnding>unix</lineEnding>
          <filtered>true</filtered>
          <outputDirectory>upload</outputDirectory>
      </file>

      <file>
          <source>src/stuff/notes/crontab-${project.layer}.txt</source>
          <destName>crontab.txt</destName>
          <lineEnding>unix</lineEnding>
          <filtered>true</filtered>
          <outputDirectory>upload</outputDirectory>
      </file>

      <!-- download files -->
      <file>
          <source>src/stuff/scripts/cars_download.sh</source>
          <lineEnding>unix</lineEnding>
          <filtered>true</filtered>
          <outputDirectory>download</outputDirectory>
      </file>

      <file>
          <source>src/stuff/notes/crontab-${project.layer}.txt</source>
          <destName>crontab.txt</destName>
          <lineEnding>unix</lineEnding>
          <filtered>true</filtered>
          <outputDirectory>download</outputDirectory>
      </file>
  </files>
</assembly>

zip文件中有两个顶级目录,上传和下载。