wupdigital / android-maven-publish

Modification of the standard Maven Publish plugin to be compatible with android-library projects (aar).
Apache License 2.0
326 stars 39 forks source link

Getting error: Cannot compare value: java-runtime #6

Closed Plinzen closed 6 years ago

Plinzen commented 6 years ago

Hello, I included your plugin into one or our projects. The project contains of one Android Application and five Android Libraries. Now, I would like to upload the libraries to our Maven-Repo.

Main build.gradle

buildscript {
    repositories {
        jcenter()
        google()
        maven { url 'https://maven.fabric.io/public' }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.0.1'
        classpath 'com.vanniktech:gradle-android-junit-jacoco-plugin:0.10.0'
        classpath 'io.fabric.tools:gradle:1.24.5'
        classpath 'org.ajoberstar:grgit:2.1.0'
        classpath 'org.owasp:dependency-check-gradle:3.0.1'
        classpath 'io.realm:realm-gradle-plugin:3.3.2'
        classpath 'digital.wup:android-maven-publish:3.1.1'
    }
}

And the build.gradle of one of our library modules:

apply plugin: 'com.android.library'
apply plugin: 'com.vanniktech.android.junit.jacoco'
apply plugin: 'org.owasp.dependencycheck'
apply from: '../gradle-src/checkstyle.gradle'
apply from: '../gradle-src/javadoc.gradle'
apply plugin: 'digital.wup.android-maven-publish'

android {
    compileSdkVersion 26
    buildToolsVersion buildVersion

    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }

    defaultConfig {
        minSdkVersion 21
        targetSdkVersion 26
        testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
        def numberOfCommits = countGitCommits()
        versionCode 8000 + numberOfCommits
        versionName "0.8.$numberOfCommits"
    }

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

    testOptions {
        unitTests.returnDefaultValues = true
    }
}

dependencies {
    implementation "io.reactivex.rxjava2:rxandroid:$rxAndroidVersion"
    implementation "io.reactivex.rxjava2:rxjava:$rxJavaVersion"
    implementation "com.android.support:support-compat:$supportLibVersion"
    implementation "com.google.dagger:dagger:$daggerVersion"
    annotationProcessor "com.google.dagger:dagger-compiler:$daggerVersion"
    // Needed for @Generated annotation (missing in Java <= 1.6; therefore, Android)
    implementation 'javax.annotation:jsr250-api:1.0'
    testImplementation "junit:junit:$junitVersion"
    testImplementation "org.mockito:mockito-core:$mockitoVersion"
    testImplementation "org.hamcrest:hamcrest-core:$hamcrestVersion"
    testImplementation "org.hamcrest:hamcrest-library:$hamcrestVersion"
    testImplementation "org.powermock:powermock-module-junit4:$powerMockVersion"
    testImplementation "org.powermock:powermock-module-junit4-rule:$powerMockVersion"
    testImplementation "org.powermock:powermock-api-mockito:$powerMockVersion"
    testImplementation "org.powermock:powermock-classloading-xstream:$powerMockVersion"
    androidTestImplementation "com.android.support:support-annotations:$supportLibVersion"
    androidTestImplementation "com.android.support.test:runner:$testSupportVersion"
    androidTestImplementation "com.android.support.test:rules:$testSupportVersion"
    androidTestImplementation "org.hamcrest:hamcrest-library:$hamcrestVersion"
    androidTestImplementation "org.mockito:mockito-core:$mockitoVersion"
    androidTestImplementation "com.google.dexmaker:dexmaker-mockito:$dexmakerVersion"
    androidTestImplementation "com.google.dexmaker:dexmaker:$dexmakerVersion"
}

publishing {
    publications {
        mavenAar(MavenPublication) {
            groupId 'de.mycompany.myapp'
            artifactId 'artifactid'
            version '1.3.0'
            from components.android
        }
    }
}

publishing {
    repositories {
        maven {
            credentials {
                username "myuser"
                password "password"
            }
            url "http://maven.myserver:8081/repository/maven-releases"
        }
    }
}

But when I sync the project with Android Studio, I am getting the following error:

cannot compare value: java-runtime

and it points to the following line:

 from components.android

Am I doing something wrong? On my machine I have Java JDK 8 installed. I am using gradle 4.1

warnyul commented 6 years ago

Try to upgrade your Gradle version to 4.2 or downgrade the android-maven-publish plugin version to 3.0.0. You can find the compatibility information in the README.md

Plinzen commented 6 years ago

Sorry, my fault! Thank you very much for your hint! 👍