I want to switch from maven to gradle.
In the pom.xml file I have a custom repository:
<repositories>
<repository>
<id>my_rep_name</id>
<url>http://*********</url>
</repository>
</repositories>
It's a simple http web server with .jar files.
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://******'
}
}
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.
To add a dependency to your project, specify a dependency configuration such as implementation in the dependencies block of your module's build.gradle file.
Maven Central is a popular repository hosting open source libraries for consumption by Java projects. To declare the Maven Central repository for your build add this to your script: Example 1. Adding central Maven repository. build.gradle.
maven {
url 'https://repo url'
credentials {
username = "username"
password = "password"
}
}
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 supports following formats: https://docs.gradle.org/current/userguide/dependency_management.html#sec:repositories
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.
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.
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 use https://www.jfrog.com/open-source/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With