Maven程序集插件重新下载Jenkins中的依赖项 [英] Maven assembly plugin redownloading dependencies in jenkins

查看:116
本文介绍了Maven程序集插件重新下载Jenkins中的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某种原因,每次我尝试使用Jenkins构建项目的依赖项时,maven似乎都试图下载该项目的依赖项.有一些问题.第一个是根本不应该执行此操作,另一个问题是它甚至没有尝试从正确的存储库中下载它们,这意味着它必须等待它们中的每个超时.

For some reason, maven seems to be attempting to download my project's dependencies every time I try to build it with Jenkins. There are a few problems. The first one is it shouldn't be doing this at all, and the other problem is it's not even trying to download them from the correct repo, which means it has to wait for every one of them to time out.

我可以自己运行mvn clean软件包,它会在大约4秒钟内完成构建,因为所有依赖项都在我的本地.m2存储库中. Jenkins是在本地安装的,并且正在共享此Maven存储库,所以我不知道为什么它的行为有所不同.看来jenkins正在发出带有-B和-f标志的maven命令,并且正在使用install而不是package,但是即使我自己这样做,它也会在几秒钟内完成,而Jenkins由于所有超时而花费了大约8分钟的时间.它必须等待.

I can run mvn clean package myself and it builds it in ~4 seconds because all of the dependencies are in my local .m2 repo. Jenkins is installed locally and is sharing this maven repo so I don't know why it's behaving differently. It appears that jenkins is issuing the maven command with -B and -f flags and is using install instead of package but even when I do this myself it does it in a few seconds whereas Jenkins takes about 8 minutes due to all of the timing out it has to wait for.

我标记了Slick2d和lwjgl库,因为我认为它们与它们有关,因为它们不在公共Maven存储库中,因此我必须手动将其存储库添加到pom中.

I tagged the Slick2d and lwjgl libraries because I think it has something to do with them as they aren't in a public maven repo and I have to add their repo's to the pom manually.

值得注意的是构建已经完成并成功完成,唯一的区别是Jenkins花费了8分钟的超时时间,而我自己却在几秒钟内完成了操作.

It's also probably worth noting that the builds finish and are successful, the only difference is Jenkins spends 8 minutes on timeouts while doing it myself happens in seconds.

此外,当我最初试图弄清楚这一点时,当我尝试手动执行此操作时也会发生这种情况.在我添加了Maven Natives Repository之后,它停止了这样做,但是我不知道为什么Jenkins仍然花时间,因为他们共享相同的本地仓库和

Also, when I was trying to figure this out originally it would also happen when I tried to do it manually. It stopped doing this after I added the Maven Natives Repository but I don't know why Jenkins is still taking its time, as they share the same local repo and

更新:尝试找出正在发生的事情之后,我似乎已将其范围缩小到与maven程序集插件相关的位置,因为如果我从pom中取出那一部分,它就可以正常工作.

Update: After trying to find out what's going on I seem to have narrowed it down to being related to the maven assembly plugin because if I take that part out of my pom it works fine.

这是我的pom文件的相关部分:

Here is the relevant pieces of my pom file:

<repositories>
    <repository>
        <id>slick</id>
        <name>slick</name>
        <url>http://slick.cokeandcode.com/mavenrepo</url>
    </repository>
    <repository>
        <id>mavenNatives</id>
        <name>Maven Natives Repository</name>
        <url>http://mavennatives.googlecode.com/svn/repo</url>
    </repository>
    <repository>
        <id>nolat.org</id>
        <name>Nolat</name>
        <url>https://raw.github.com/Talon876/repo/master/releases</url>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.8.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
    </dependency>
    <dependency>
        <groupId>org.nolat</groupId>
        <artifactId>toolkit</artifactId>
        <version>1.0</version>
    </dependency>
    <dependency>
        <groupId>org.lwjgl.lwjgl</groupId>
        <artifactId>lwjgl</artifactId>
        <version>2.8.3</version>
    </dependency>
    <dependency>
        <groupId>slick</groupId>
        <artifactId>slick</artifactId>
        <version>274</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        [...]
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <version>2.3</version>
            <executions>
                <execution>
                    <id>jar-with-dependencies</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <descriptorRefs>
                            <descriptorRef>jar-with-dependencies</descriptorRef>
                        </descriptorRefs>
                        <archive>
                            <manifest>
                                <mainClass>${main}</mainClass>
                                <addClasspath>true</addClasspath>
                            </manifest>
                        </archive>
                        <appendAssemblyId>false</appendAssemblyId>
                    </configuration>
                </execution>
                <execution>
                    <id>dist</id>
                    <phase>package</phase>
                    <goals>
                        <goal>single</goal>
                    </goals>
                    <configuration>
                        <descriptors>
                            <descriptor>src/META-INF/dist.xml</descriptor>
                        </descriptors>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
 </build>

这是Jenkins控制台的相关部分(在放弃并继续之前,每个下载行都放置了一段时间):

And here is the relevant pieces of the Jenkins console (Each of the downloading lines is where it sits for awhile before giving up and continuing):

[JENKINS] Recording test results
mojoStarted org.apache.maven.plugins:maven-jar-plugin:2.3.2(default-jar)
[INFO] 
[INFO] --- maven-jar-plugin:2.3.2:jar (default-jar) @ Falldown ---
mojoSucceeded org.apache.maven.plugins:maven-jar-plugin:2.3.2(default-jar)
mojoStarted org.apache.maven.plugins:maven-assembly-plugin:2.3(jar-with-dependencies)
[INFO] 
[INFO] --- maven-assembly-plugin:2.3:single (jar-with-dependencies) @ Falldown ---
Downloading: http://slick.cokeandcode.com/mavenrepo/phys2d/phys2d/060408/phys2d-    060408.pom
Downloading: http://mavennatives.googlecode.com/svn/repo/phys2d/phys2d/060408/phys2d-060408.pom
Downloading:     https://raw.github.com/Talon876/repo/master/releases/phys2d/phys2d/060408/phys2d-060408.pom
Downloading: http://repo.maven.apache.org/maven2/phys2d/phys2d/060408/phys2d-060408.pom
Downloading: http://slick.cokeandcode.com/mavenrepo/org/lwjgl/lwjgl/2.1.0/lwjgl-2.1.0.pom
Downloading: http://mavennatives.googlecode.com/svn/repo/org/lwjgl/lwjgl/2.1.0/lwjgl-  2.1.0.pom
Downloading:    https://raw.github.com/Talon876/repo/master/releases/org/lwjgl/lwjgl/2.1.0/lwjgl-2.1.0.pom
Downloading: http://repo.maven.apache.org/maven2/org/lwjgl/lwjgl/2.1.0/lwjgl-2.1.0.pom
Downloading: http://slick.cokeandcode.com/mavenrepo/org/lwjgl/lwjgl-jinput/2.1.0/lwjgl-jinput-2.1.0.pom
Downloading: http://mavennatives.googlecode.com/svn/repo/org/lwjgl/lwjgl-   jinput/2.1.0/lwjgl-jinput-2.1.0.pom
Downloading: https://raw.github.com/Talon876/repo/master/releases/org/lwjgl/lwjgl- jinput/2.1.0/lwjgl-jinput-2.1.0.pom
Downloading: http://repo.maven.apache.org/maven2/org/lwjgl/lwjgl-jinput/2.1.0/lwjgl-jinput-2.1.0.pom
Downloading: http://slick.cokeandcode.com/mavenrepo/org/lwjgl/lwjgl-native/2.1.0/lwjgl-native-2.1.0.pom
Downloading: http://mavennatives.googlecode.com/svn/repo/org/lwjgl/lwjgl-native/2.1.0/lwjgl-native-2.1.0.pom
Downloading: https://raw.github.com/Talon876/repo/master/releases/org/lwjgl/lwjgl-native/2.1.0/lwjgl-native-2.1.0.pom
Downloading: http://repo.maven.apache.org/maven2/org/lwjgl/lwjgl-native/2.1.0/lwjgl-native-2.1.0.pom
Downloading: http://slick.cokeandcode.com/mavenrepo/javax/jnlp/jnlp/1.2/jnlp-1.2.pom
Downloading: http://mavennatives.googlecode.com/svn/repo/javax/jnlp/jnlp/1.2/jnlp-1.2.pom
Downloading: https://raw.github.com/Talon876/repo/master/releases/javax/jnlp/jnlp/1.2/jnlp-1.2.pom
Downloading: http://repo.maven.apache.org/maven2/javax/jnlp/jnlp/1.2/jnlp-1.2.pom
Downloading: http://slick.cokeandcode.com/mavenrepo/ibxm/ibxm/unknown/ibxm-unknown.pom
Downloading: http://mavennatives.googlecode.com/svn/repo/ibxm/ibxm/unknown/ibxm-unknown.pom
Downloading: https://raw.github.com/Talon876/repo/master/releases/ibxm/ibxm/unknown/ibxm-unknown.pom
Downloading: http://repo.maven.apache.org/maven2/ibxm/ibxm/unknown/ibxm-unknown.pom
Downloading: http://slick.cokeandcode.com/mavenrepo/jcraft/jogg/0.0.7/jogg-0.0.7.pom
Downloading: http://mavennatives.googlecode.com/svn/repo/jcraft/jogg/0.0.7/jogg-0.0.7.pom
Downloading: https://raw.github.com/Talon876/repo/master/releases/jcraft/jogg/0.0.7/jogg-0.0.7.pom
Downloading: http://repo.maven.apache.org/maven2/jcraft/jogg/0.0.7/jogg-0.0.7.pom
Downloading: http://slick.cokeandcode.com/mavenrepo/jcraft/jorbis/0.0.15/jorbis-0.0.15.pom
Downloading: http://mavennatives.googlecode.com/svn/repo/jcraft/jorbis/0.0.15/jorbis-0.0.15.pom
Downloading: https://raw.github.com/Talon876/repo/master/releases/jcraft/jorbis/0.0.15/jorbis-0.0.15.pom
Downloading: http://repo.maven.apache.org/maven2/jcraft/jorbis/0.0.15/jorbis-0.0.15.pom
[WARNING] Artifact: org.nolat:Falldown:jar:1.0-SNAPSHOT references the same file as the assembly destination file. Moving it to a temporary location for inclusion.
[INFO] META-INF/ already added, skipping
[INFO] META-INF/MANIFEST.MF already added, skipping
[INFO] org/ already added, skipping
...and so on

推荐答案

获得稳定的Maven构建的第一步是使用Maven仓库管理器,例如

The first step to get stable Maven builds is to use a Maven Repository Manager such as Nexus.

  • Install the Maven Repoitory Manager (like Jenkins you can install Nexus locally if you are the only developer)
  • Configure Maven to use a single Nexus group. You have to do this for every user, also for the Jenkins user if you have a dedicated system user to run Jenkins (recommended approach). If you're using a different Maven Repository Manager than Nexus, check the documentation.
  • Only define repositories in your Maven Repository Manager. No repositories sections in your POMs!

完成此操作后,请检查行为并告诉我们是否有任何问题.

Once you've done this check the behaviour and tell us if you have any issues.

这篇关于Maven程序集插件重新下载Jenkins中的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆