【问题标题】:maven assembly transitive dependency not added未添加 maven 程序集传递依赖项
【发布时间】:2013-10-21 07:58:40
【问题描述】:

我有以下带有几个模块的 maven 父项目

<parent>
        <artifactId>ppdf-3party-demo</artifactId>
        <groupId>edu.i2r</groupId>
        <version>1.0</version>
    </parent>

    <groupId>edu.i2r</groupId>
    <artifactId>ppdf-3party-demo-client</artifactId>
    <version>1.0</version>
    <packaging>pom</packaging>

    <name>ppdf-3party-demo-client</name>

    <modules>
        <module>demo-client-app</module>
        <module>demo-client-model</module>
        <module>demo-client-persist</module>
        <module>demo-client-swing</module>
        <module>demo-client-encryptservice</module>
    </modules>

    <dependencies>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat</artifactId>
            <version>7.0.35</version>
            <type>zip</type>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptors>
                        <descriptor>src/main/assembly/bin-package.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>distro-assembly</id>
                        <!-- <phase>package</phase> -->
                        <!-- <goals> -->
                        <!-- <goal>single</goal> -->
                        <!-- </goals> -->
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <id>unpack-tomcat</id>
                        <phase>process-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.apache.tomcat</groupId>
                                    <artifactId>tomcat</artifactId>
                                    <version>7.0.35</version>
                                    <type>zip</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

        </plugins>
        <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
                <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.4,)
                                        </versionRange>
                                        <goals>
                                            <goal>unpack</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>

demo-client-persist内部我依赖spring-jdbc

    <parent>
    <groupId>edu.i2r</groupId>
    <artifactId>ppdf-3party-demo-client</artifactId>
    <version>1.0</version>
  </parent>

  <artifactId>demo-client-persist</artifactId>
  <name>demo-client-persist</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>edu.i2r</groupId>
      <artifactId>demo-client-model</artifactId>
      <version>1.0</version>
    </dependency>
    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-jdbc</artifactId>
      <version>3.1.1.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>edu.i2r</groupId>
      <artifactId>ppdf-demo-common</artifactId>
      <version>1.0</version>
    </dependency>
  </dependencies>
</project>

最后,我有以下程序集描述符

  <includeBaseDirectory>false</includeBaseDirectory>
  <dependencySets>
    <dependencySet>
        <outputDirectory>lib</outputDirectory>
        <scope>runtime</scope>
    </dependencySet>
  </dependencySets>
  <fileSets>

运行mvn assembly:assembly,输出目录似乎工作,因为依赖项被复制到lib目录。但是,只有 spring-jdbc jar 不存在。

我错过了什么吗?

【问题讨论】:

  • 恐怕调试这将需要整个父级和demo-client-persist POM;这看起来像是dependencyManagement 中的范围问题。另请注意,除assembly:single 之外的所有目标均已弃用。
  • @chrylis 更新了父组件和模块 pom。
  • über父pom:ppdf-3party-demo的内容是什么?它有dependencyManagement 部分吗?
  • 当您使用SNAPSHOT 版本时是否包含spring-jdbc

标签: java maven


【解决方案1】:

在一开始的构建过程中可能会出现错误,说明由于此错误,传递依赖项已被禁用。

【讨论】:

    【解决方案2】:

    运行mvn assembly:assembly 时可能会忽略某些警告。

    ## [WARNING] Invalid POM for ${group}:${artifact}:${type}:${version}, transitive dependencies (if any) will not be available, enable debug logging for more details
     ##
    

    您可以使用选项“-X”运行 maven 以查看详细信息。在我的情况下,通过删除本地 maven 缓存 (~/.m2) 中的 _remote.repositories 文件来解决问题

    您可能想看看这篇文章:"The POM for ... is missing, no dependency information available" even though it exists in Maven Repository

    【讨论】:

      猜你喜欢
      • 2014-04-25
      • 2020-03-01
      • 2013-02-17
      • 2016-02-23
      • 1970-01-01
      • 2016-05-14
      • 1970-01-01
      • 1970-01-01
      • 2010-11-05
      相关资源
      最近更新 更多