0

When deploying with $mvn deploy for a linked artifact into JCenter, I get this error Return code is: 401, ReasonPhrase: Unauthorized.

What is causing this, and how to fix this?

quarks
  • 33,478
  • 73
  • 290
  • 513
  • Have you seen [Why am I getting a “401 Unauthorized” error in Maven?](http://stackoverflow.com/questions/24830610/why-am-i-getting-a-401-unauthorized-error-in-maven) already? – Gerold Broser Oct 26 '15 at 21:01
  • Possible duplicate of [Maven hosting with Bintray](http://stackoverflow.com/questions/25610068/maven-hosting-with-bintray) – JBaruch Oct 29 '15 at 18:10

2 Answers2

0

Solution is to have this in the artifact's pom.xml

<distributionManagement>
    <snapshotRepository>
        <id>bintray-yourusername-maven-yourpackagename</id> <!-- same id with the server in settings.xml -->
        <name>oss-jfrog-artifactory-snapshots</name>
        <url>http://oss.jfrog.org/artifactory/oss-snapshot-local</url>
    </snapshotRepository>
</distributionManagement>

And have this in the settings.xml

<?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'>
   <servers>
        <server>
            <id>bintray-yourusername-maven-yourpackagename</id> <!-- same id with the snapshotRepository -->
            <username>yourusername</username>
            <password>your_api_key</password>
        </server>
    </servers>
    <profiles>
        <profile>
            <repositories>
                <repository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray</name>
                    <url>http://jcenter.bintray.com</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray-plugins</name>
                    <url>http://jcenter.bintray.com</url>
                </pluginRepository>
            </pluginRepositories>
            <id>bintray</id>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>bintray</activeProfile>
    </activeProfiles>
</settings>
quarks
  • 33,478
  • 73
  • 290
  • 513
  • For whoever reads this is thinks it's the correct answer, please keep in mind that this anwer is NOT fixing the 401 for deploying SNAPSHOTs to Bintray. You'll always get 401 trying to do so. This answer actually shows how to use Artifactory for SNAPSHOTs instead of Bintray. Please see my answer for instructions on how to get your account on oss.jfrog.org etc. – JBaruch Oct 30 '15 at 16:36
  • @JBaruch I wonder why this worked for me, oh yes, I made sure the the artifact is linked in JCenter :-) – quarks Oct 30 '15 at 18:46
  • You did the right thing – put the snapshots into oss.jfrog.org (see the repo url in `distribution-management`). – JBaruch Oct 30 '15 at 18:52
0

Without seeing your pom file, my bet is you're trying to upload a SNAPSHOT to Bintray. Bintray is a distribution platform and intended for releases only.

You're more than welcome to use oss.jfrog.org for snapshots of packages, which are included in JCenter.

JBaruch
  • 22,610
  • 5
  • 62
  • 90