mschonaker / wagon-git

Git Wagon for Apache Maven
http://synergian.github.io/wagon-git/
83 stars 32 forks source link

Cannot consume android artifact from bitbucket #57

Open megaurko opened 5 years ago

megaurko commented 5 years ago

I have a private bitbucket repository which I'm deploying artifacts to with wagon-git. When I'm trying to consume the artifact in my android project I get this:

ERROR: Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.nextcom.universalxmlpullparser:uxpp:2.0.1.

I have tried using both v1 and v2 bitbucket API URL format but no luck.

        maven {
            url 'https://api.bitbucket.org/2.0/repositories/megaurko/universalxmlpullparser_artifacts/src/releases'
            credentials {
                 ...
            }
        }
vduits commented 5 years ago

I'll try and provide a detailed answer in case someone else gets across this issue.

The authentication flow has changed requiring an username and app password to be passed. You can do it either using pre-emptive or with http headers.

I don't know your setup but I prefer using an init.gradle file in my .gradle user folder. Which means you don't include any information in your project to accidentally commit. So inside the build.gradle file I only need to have the dependency as if it was from the public maven.

The following two examples I used @ to describe user input. Using pre-emptive:

allprojects {
    repositories {
        mavenLocal()
        maven {
            url 'https://api.bitbucket.org/2.0/repositories/@bitbucket-username@/@repository-name@/src/releases'
            credentials {
                username "@username@"
                password "@app-password@"
            }
            authentication {
                basic(BasicAuthentication)
            }
        }
    }
}

I personally like to encode it beforehand, using header authentication.

allprojects {
    repositories {
        mavenLocal()
        maven {
            url "https://api.bitbucket.org/2.0/repositories/@bitbucket-username@/@repository-name@/src/releases"
            credentials(HttpHeaderCredentials) {
                name = "Authorization"
                value = "Basic @EncodedUsernameAndAppPassword@"
            }
            authentication {
                header(HttpHeaderAuthentication)
            }
        }
    }
}
v5b7c6 commented 3 years ago

excuse me Is this problem solved?

renatoramos7 commented 3 years ago

Hey guys look this tuto.. I fixed with this in a private repo

// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() mavenCentral() }

dependencies {
    classpath "com.android.tools.build:gradle:4.2.1"
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
    classpath "com.google.dagger:hilt-android-gradle-plugin:2.36"
}

}

Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream())

def USERNAME = properties.getProperty('USERNAME') def PASSWORD = properties.getProperty('PASSWORD')

allprojects { repositories { google() mavenCentral()

    maven {
       url "https://api.bitbucket.org/2.0/repositories/" + COMPANY + "/" + REPOSITORY_NAME + "/src/releases"

       credentials {
            username USERNAME
            password PASSWORD
        }

        authentication {
            basic(BasicAuthentication)
        }
    }
}

}

task clean(type: Delete) { delete rootProject.buildDir }

https://gorillalogic.com/blog/a-bitbucket-tutorial-creating-a-private-repository-for-an-android-library/