简体   繁体   English

Maven-为什么Maven除了jar文件之外不会下载依赖项pom

[英]Maven - why maven won't download the dependency pom in addition to the jar file

I have a Maven project. 我有一个Maven项目。 One of my dependencies is a zip file. 我的依赖项之一是zip文件。 Maven downloads this zip file to the local repository but the pom file is not there too. Maven将此zip文件下载到本地存储库,但pom文件也不在那里。 How can I instruct Maven to download also the pom file? 我如何指示Maven也下载pom文件? the type of my dependency is zip. 我依赖的类型是zip。

the pom file exists in the remote repository. pom文件存在于远程存储库中。 the pom file: pom文件:

<modelVersion>4.0.0</modelVersion>
<groupId>com.g.g</groupId>
<artifactId>art</artifactId>
<name>art</name>
<version>1-SNAPSHOT</version>
<packaging>pom</packaging>


<build>

    <plugins>
         <plugin>
            <artifactId>maven-assembly-plugin</artifactId>

            <configuration>

                <descriptors>
                    <descriptor>createZip.xml</descriptor>
                </descriptors>

            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution> 
            </executions>
        </plugin> 
    </plugins>

</build>

the deploy command: deploy命令:

call mvn clean install
call mvn deploy:deploy-file -Durl=url -Dpackaging=zip -Dfile="%~dp0\target\art-1-SNAPSHOT.zip" -DgroupId=com.g.g -DartifactId=art -Dversion=1-SNAPSHOT -DrepositoryId=... -DpomFile="pom.xml"

the dependency: 依赖项:

<dependency>
<groupId>com.g.g</groupId>
<artifactId>art</artifactId>    
<version>1-SNAPSHOT</version>
<type>zip</type>        

If you want both the zip and the pom, you may specify them both as dependencies. 如果同时需要zip和pom,则可以将它们都指定为依赖项。

<dependency>
<groupId>com.g.g</groupId>
<artifactId>art</artifactId>    
<version>1-SNAPSHOT</version>
<type>zip</type> 

<dependency>
<groupId>com.g.g</groupId>
<artifactId>art</artifactId>    
<version>1-SNAPSHOT</version>
<type>pom</type> 

Another way to do it if you don't want to specify the pom as a dependency: the Maven dependency plugin has a get mojo that allows downloading of named artifacts from a remote repository. 如果您不想将pom指定为依赖项,则可以使用另一种方法:Maven依赖项插件具有get mojo ,它允许从远程存储库下载命名的工件。

This could be because the packaging in the pom.xml differs from the packaging of the dependency. 这可能是因为packagingpom.xml从依赖的包装不同。 While pom.xml has the packaging as pom , the actual dependency packaging is zip . 尽管pom.xml的打包方式为pom ,但实际的依赖打包方式为zip

Try changing the <packaging> in pom.xml to zip and see if addresses the issue. 尝试将pom.xml<packaging>更改为zip ,看看是否可以解决该问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM