mark-vieira / gradle-maven-settings-plugin

Gradle Maven settings plugin
Apache License 2.0
60 stars 27 forks source link

Plugin not working on Android library modules #23

Open Tharkius opened 3 years ago

Tharkius commented 3 years ago

Every time I try to use this plugin for authenticating to a custom repo from an Android lib module, I get the following error (it will just refuse to search for the lib in the repo I defined):

Could not find some.repo.libs:some-lib:1.1.0.
Searched in the following locations:
  - https://dl.google.com/dl/android/maven2/some/repo/libs/some-lib/1.1.0/some-lib-1.1.0.pom
  - https://jcenter.bintray.com/some/repo/libs/some-lib/1.1.0/some-lib-1.1.0.pom
  - https://jitpack.io/some/repo/libs/some-lib/1.1.0/some-lib-1.1.0.pom
  - https://maven.fabric.io/public/some/repo/libs/some-lib/1.1.0/some-lib-1.1.0.pom
Required by:
    project :app > project :libtest

If I configure the repo from an app module like this, it works just fine:

plugins {
    id "net.linguica.maven-settings" version "0.5"
}

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

repositories {
    maven { url "https://jitpack.io" }
    maven { url 'https://maven.fabric.io/public' }

    maven {
        url 'https://some.repo.com'
        name 'some.repo.libs'
        authentication {
            basic(BasicAuthentication)
        }
    }
}

android {
    compileSdkVersion computeCompileSdkVersion().toInteger()
    buildToolsVersion computeBuildToolsVersion()

    defaultConfig {
        applicationId "com.example.libtest"
        minSdkVersion computeMinSdkVersion().toInteger()
        targetSdkVersion computeTargetSdkVersion().toInteger()
        versionCode computeVersionCode().toInteger()
        versionName computeVersionName()
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
    implementation 'androidx.core:core-ktx:1.3.2'
    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'some.repo.libs:some-lib:1.1.0'

    implementation project (path: ':libtest')
}

But if I try the same for a lib module like this, I always get that error mentioned above:

apply plugin: 'com.android.library'

android {
    compileSdkVersion computeCompileSdkVersion().toInteger()
    buildToolsVersion computeBuildToolsVersion()

    defaultConfig {
        minSdkVersion computeMinSdkVersion().toInteger()
        targetSdkVersion computeTargetSdkVersion().toInteger()
        versionCode computeVersionCode().toInteger()
        versionName computeVersionName()
        resConfigs "en","pt"
    }

    lintOptions {
        abortOnError false
    }

    compileOptions {
        targetCompatibility JavaVersion.VERSION_1_8
        sourceCompatibility JavaVersion.VERSION_1_8
    }
}

repositories {
    google()

    maven { url "https://jitpack.io" }
    maven { url 'https://maven.fabric.io/public' }

    maven {
        url 'https://some.repo.com'
        name 'some.repo.libs'
        authentication {
            basic(BasicAuthentication)
        }
    }
}

dependencies {
    implementation 'some.repo.libs:some-lib:1.1.0'
}