问题描述
我想从Maven切换到Gradle.
I want to switch from maven to gradle.
在pom.xml文件中,我有一个自定义存储库:
In the pom.xml file I have a custom repository:
<repositories>
<repository>
<id>my_rep_name</id>
<url>http://*********</url>
</repository>
</repositories>
这是带有.jar文件的简单http Web服务器.
It's a simple http web server with .jar files.
如何将此自定义存储库添加到build.gradle?
How can I add this custom repo to the build.gradle?
我尝试了这段代码,但是它不起作用:
I tried this code, but it does not work:
repositories {
mavenCentral()
maven {
url 'http://******'
}
}
我的自定义存储库不是Maven存储库,但是在Gradle文档中找不到可以指定URL的其他示例.
My custom repo is not a maven repo, but I did not find another examples in the Gradle documentation where I can specify the URL.
推荐答案
maven {
url 'https://repo url'
credentials {
username = "username"
password = "password"
}
}
明确地是要走的路(对于Maven存储库).您正在使用哪个版本的gradle?您收到什么错误消息?也许在该自定义存储库中找不到您要解决的人工制品?
Is definetly the way to go (for maven repository). What version of gradle are you using? What error message do you get? Maybe artefact you are trying to resolve is not to be found in that custom repository?
Gradle支持以下格式: https://docs.gradle.org/current/userguide/dependency_management.html #sec:存储库
Gradle supports following formats:https://docs.gradle.org/current/userguide/dependency_management.html#sec:repositories
- 行家
- ivy
- 平面目录
对于既不是Maven也不是Ivy的外部存储库,我认为您必须回退到平面目录.您必须将所需的jar文件复制到自己的项目中,并将其用作平面目录存储库.
For external repository that is neither Maven nor Ivy, I think you have to fallback to flat directory. You have to copy required jars to your own project and use it as flat directory repository.
平面目录存储库也可以用作适当的maven存储库的穷人替换".您可以创建目录结构,在其中放置文件(您的依赖项),然后签出该目录.然后其他项目将使用此目录中的依赖项.
Flat directory repository may also be used as 'poor's man replacement' for proper maven repository. You may create directory structure, put files (your dependencies) there, then checkout this directory. Then other project would use dependencies from this directory.
当您有许多项目之间共享的许多自定义工件时,人们通常会设置自己的Maven存储库(Maven格式)并将其用于此类自定义依赖项.要设置自己的存储库,您可以使用 https://www.jfrog.com/open-source/
When you have many custom artifacts that are shared among many projects people usually setup their own maven repository (Maven-format) and use it for such custom dependencies. To setup your own repository you may usehttps://www.jfrog.com/open-source/
这篇关于如何将自定义存储库添加到Gradle构建文件中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!