简体   繁体   English

Travis CI没有使用pom.xml中提供的额外Maven存储库

[英]Travis CI not using extra Maven repository provided in pom.xml

I have a Java-based GitHub project, fitnessjiffy-spring (I'm currently focused on the "bootstrap" branch). 我有一个基于Java的GitHub项目, fitnessjiffy-spring (我目前专注于“bootstrap”分支)。 It depends on a library built from another GitHib project, fitnessjiff-etl . 它取决于从另一个GitHib项目( fitnessjiff- etl)构建的库。 I am trying to configure both of these to be built by Travis CI. 我正在尝试配置由Travis CI构建的这两个。

Unfortunately, Travis is not as sophisticated as Jenkins or Hudson in dealing with Maven-based Java projects. 不幸的是,Travis在处理基于Maven的Java项目时并不像Jenkins或Hudson那样复杂。 Jenkins can easily handle dependencies between projects, but the same concept doesn't seem to exist with Travis. Jenkins可以轻松处理项目之间的依赖关系,但Travis似乎并不存在相同的概念。 If one project depends on another, then that other project must already be built previously... and its artifact uploaded to some Maven repo where the first project can download it later. 如果一个项目依赖于另一个项目,那么其他项目必须先前已经构建...并且其工件上传到某个Maven仓库,第一个项目可以在以后下载。

My "fitnessjiffy-etl" library is building and deploying just fine. 我的“fitnessjiffy-etl”图书馆正在建设和部署。 I'm using Bintray for Maven repository hosting, and you can clearly see my artifacts over plain HTTP at: 我正在使用Bintray进行Maven存储库托管,您可以通过以下方式在纯HTTP上清楚地看到我的工件:

http://dl.bintray.com/steve-perkins/maven/ http://dl.bintray.com/steve-perkins/maven/

In my "fitnessjiffy-spring" project, I am adding this Maven repo location directly in the pom.xml , so that Travis will be able to find that artifact dependency. 在我的“fitnessjiffy-spring”项目中,我将这个Maven repo位置直接添加到pom.xml ,以便Travis能够找到该工件依赖项。 Here is the state of my POM at the time of this writing . 这是我撰写本文时POM的状态 Note the <repositories> element at the bottom of the file. 请注意文件底部的<repositories>元素。

When I build this project locally, it works just fine. 当我在本地构建这个项目时,它工作正常。 I can see it downloading the Maven artifact from " http://dl.bintray.com/ ...". 我可以看到它从“ http://dl.bintray.com/ ...”下载Maven工件。 However, when I try to build on Travis CI it fails every time. 但是,当我尝试在Travis CI上构建时,它每次都会失败。 I can see in the console log that Travis is still trying to download the artifact from Maven Central rather than my specified repo. 我可以在控制台日志中看到Travis仍在尝试从Maven Central下载工件而不是我指定的repo。

Does this make sense to anyone else? 这对其他人有意义吗? Why does Maven utilize a custom repository location in a POM file when building locally, but ignores this configuration when running on a Travis CI build? 为什么Maven在本地构建时在POM文件中使用自定义存储库位置,但在Travis CI构建上运行时忽略此配置?

From digging into this further, I discovered that Travis uses its own proxy for Maven Central, and has configured Maven to force ALL dependency requests through their proxy. 从进一步挖掘到这一点,我发现Travis使用自己的Maven Central代理,并已配置Maven通过其代理强制所有依赖请求。 In other words, it does not seem possible at this time to use additional Maven repos specified in the POM file of a project built on Travis. 换句话说,目前似乎不可能使用在Travis上构建的项目的POM文件中指定的其他Maven repos。

In my case, I ended up refactoring such that project would not need the outside JAR dependency. 在我的情况下,我最终重构,使得项目不需要外部JAR依赖。 I also switched to Drone.io, so I could manage my settings on the build server rather than having to carry a YAML file in my repository (which always struck me as a bit daft). 我也切换到Drone.io,所以我可以在构建服务器上管理我的设置,而不是在我的存储库中携带一个YAML文件(这总是让我觉得有点愚蠢)。

However, even on Drone it's still a major hassle to manage dependencies between multiple projects (extremely common with Java development). 但是,即使在Drone上,管理多个项目之间的依赖关系仍然是一个主要的麻烦(在Java开发中非常常见)。 For Java, I just don't think there's currently an adequate substitute for Jenkins or Hudson, maybe running on a cheap Digital Ocean droplet or some other VPS provider instance. 对于Java,我认为目前没有足够的替代品可以替代Jenkins或Hudson,也许可以运行在廉价的Digital Ocean Droplet或其他VPS提供商实例上。

In your install phase add a $HOME/.m2/settings.xml define your custom repository. 在安装阶段,添加$HOME/.m2/settings.xml定义您的自定义存储库。

cache:
  directories:
  - "$HOME/.m2"
install:
- curl -o $HOME/.m2/settings.xml
  https://raw.githubusercontent.com/trajano/trajano/master/src/site/resources/settings.xml
- mvn dependency:go-offline
script:
- mvn clean install site

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

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