如何向我的Travis-CI Maven构建中添加第3方JAR? [英] How can I add a 3rd party JAR to my Travis-CI maven build?
问题描述
我有一个项目,该项目使用没有Maven存储库的JAR. 我自己做的.
I have a project that uses a JAR with no maven repo. I made this by myself.
在构建项目之前,请在控制台上执行此操作:
Before build my project, I do this on my console:
mvn install:install-file -Dfile=myownjar-1.5.jar -DgroupId=com.cmabreu -DartifactId=mylocal-lib -Dversion=1.5 -D packaging=jar -DgeneratePom=true
,然后将JAR添加到我的Maven存储库(本地)中. 然后,将所需的依赖项标签添加到我的POM文件中,并构建我的项目.
and add the JAR to my maven repo (local). Then I add the required dependency tag to my POM file and build my project.
但是,当我提交到Github时,我不会发送自定义的JAR(是另一个项目).
But, when I commit to Github, I do not send my custom JAR (is another project).
问题是:如何告诉Travis-CI在其存储库中使用此自定义JAR来构建我的项目,而无需将其发送到Github?
The question is: how can I tell Travis-CI to build my project using this custom JAR in its repository without send it to Github?
推荐答案
不是推荐的解决方案,而是一种非常有用的解决方法:
Not a recommended solution but a very useful workaround:
-
在项目主目录中创建一个目录.称之为
Make a directory inside project's home. Let's call it
$ projectBasseDir/lib
$projectBasseDir/lib
将所有外部jar放入此文件夹.
Put all your external jars in this folder.
在pom文件中为您的依赖项添加作用域和systemPath,如下所示:
< scope>system< /scope >
< systemPath>${project.basedir}/lib/yourJar.jar< /systemPath>
In the pom file add scope and systemPath as follows for your dependency:
< scope>system< /scope >
< systemPath>${project.basedir}/lib/yourJar.jar< /systemPath>
将此lib/目录推送到github上的项目存储库中
Push this lib/ directory to your project repo on github
如果罐子不在本地存在,那么我们需要在您的仓库中添加一个before_start脚本,基本上可以做到这一点:
mkdir lib/
wget -P "lib/" http://urlForYourJar.jar
If the jars are not present locally, then we need to add a before_start script to your repo which basically does this:
mkdir lib/
wget -P "lib/" http://urlForYourJar.jar
它再次发挥作用.
这篇关于如何向我的Travis-CI Maven构建中添加第3方JAR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!