How to properly specify jcenter repository in maven config?
Asked Answered
H

3

23

In Gradle, I need simply add:

  repositories {  
   jcenter()  
  }

What is the simplest and proper way to do the same in maven pom.xml or where can I get right url for jcenter repository.

Hecklau answered 30/5, 2017 at 14:53 Comment(1)
Yo can use this settings.xml example. You can use this as referenceMcdermott
C
27

You have to define settings.xml like the following. If you define it in ~/.m2/settings.xml it will be global to your maven. If you define it as a resource of your project you can bind it with the -s parameter:

mvn -s settings.xml compile

<?xml version="1.0" encoding="UTF-8" ?>
<settings xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd'
          xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
    
    <profiles>
        <profile>
            <repositories>
                <repository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray</name>
                    <url>https://jcenter.bintray.com</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray-plugins</name>
                    <url>https://jcenter.bintray.com</url>
                </pluginRepository>
            </pluginRepositories>
            <id>bintray</id>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>bintray</activeProfile>
    </activeProfiles>
</settings>
Contradict answered 1/6, 2017 at 9:51 Comment(1)
As of Jun 2020 JCenter is only available over HTTPS. So url adresses here must be changed to https.Admeasurement
R
23

Just add a repositories section in your pom:

<repositories>
    <repository>
        <id>jcenter</id>
        <name>jcenter</name>
        <url>https://jcenter.bintray.com</url>
    </repository>
</repositories>
Richie answered 3/8, 2020 at 3:9 Comment(1)
url can be copied from the upper right corner of the repository page. For example, Spring releases repository has https://dl.bintray.com/spring/jars maven repository urlHackbut
B
13

The official documentation from JFrog JCenter is in: https://bintray.com/bintray/jcenter

Hit the SET ME UP! button on the upper right corner.

SET ME UP!

Burnet answered 14/6, 2017 at 15:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.