简体   繁体   English

如何在 CircleCI 上为 Maven 包含外部库

[英]How to include external library for maven on CircleCI

I am using circleCI for a webapp's continuous integration which is built with maven.我正在将 circleCI 用于使用 maven 构建的 webapp 的持续集成。 I want to let maven use an external library when running test and building on CircleCI.我想让 maven 在运行测试和在 CircleCI 上构建时使用外部库。
Since the library has just an artifact of a sibling project in a larger parent maven project, I can build this project without any problem on my local environment because I've already add it as a dependency in my pom.xml.由于该库在较大的父 maven 项目中只有一个兄弟项目的工件,因此我可以在本地环境中毫无问题地构建这个项目,因为我已经将它作为依赖项添加到我的 pom.xml 中。
I have tried to add the built jar file into M2_HOME manually with circle.yml and bash file below.我尝试使用下面的 circle.yml 和 bash 文件手动将构建的 jar 文件添加到 M2_HOME 中。

circle.yml:圆.yml:

#...
dependencies:
    pre:
        - sudo chmod a+x add_dependencies.sh
        - ./add_dependencies.sh
#...

add_dependencies.sh: add_dependencies.sh:

sudo wget http://my.jar.file.url -O exteral_lib.jar --quiet
sudo mkdir -p ${HOME}/.m2/repository/com/group/artifact/1.0.0/
sudo cp -rl ./exteral_lib.jar ${HOME}/.m2/repository/com/group/artifact/1.0.0/exteral_lib.jar
sudo rm -f ./exteral_lib.jar

But it didn't work.但它没有用。

Failed to create parent directories for tracking file, 
Non-resolvable import POM: Could not transfer artifact 

happened when CircleCI trying to resolve dependencies.当 CircleCI 尝试解决依赖关系时发生。

How can I solve this problem?我怎么解决这个问题?

Instead of copying the jar to the repository, you could try to install it:您可以尝试安装它,而不是将 jar 复制到存储库:

mvn install:install-file -DgroupId=<your group id> -DartifactId=<your artifact id> -Dversion=<your version id> -Dpackaging=jar -Dfile=<your jar filename> -DgeneratePom=true

Example:例子:

mvn install:install-file -DgroupId=com.microsoft.sqlserver -DartifactId=sqljdbc -Dversion=4.2 -Dpackaging=jar -Dfile=sqljdbc.jar -DgeneratePom=true

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

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