diff --git a/build.gradle b/build.gradle index 43f2d4b9..a200b5ba 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,7 @@ subprojects { classpath dep.groovyPlugin classpath dep.kotlinPlugin classpath dep.okreplayPlugin + classpath dep.gradleMavenPublishPlugin } } diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 727b87bf..07e4a248 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -10,35 +10,40 @@ ext { isCi = "true" == System.getenv('CI') dep = [ - androidPlugin : 'com.android.tools.build:gradle:3.5.0', - groovyPlugin : 'org.codehaus.groovy:groovy-android-gradle-plugin:1.1.0', - nexusPlugin : 'com.bmuschko:gradle-nexus-plugin:2.3.1', - appcompat : "androidx.appcompat:appcompat:$versions.appCompatVersion", - androidXAnnotations : "androidx.annotation:annotation:1.0.1", - groovy : "org.codehaus.groovy:groovy-all:2.4.5:indy", - guava : "com.google.guava:guava:25.0-android", - guava_jre : "com.google.guava:guava:25.0-jre", - ddmlib : 'com.android.tools.ddms:ddmlib:25.3.0', - junit : "junit:junit:4.12", - cglib : "cglib:cglib-nodep:2.2.2", - jsr305 : "com.google.code.findbugs:jsr305:3.0.2", - mockito : 'org.mockito:mockito-core:2.7.13', - okio : 'com.squareup.okio:okio:1.17.2', - okhttp : "com.squareup.okhttp3:okhttp:$versions.okhttpVersion", - mockWebServer : "com.squareup.okhttp3:mockwebserver:$versions.okhttpVersion", - snakeYaml : "org.yaml:snakeyaml:1.16", - kotlinStdLib : "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlinVersion", - okreplayPlugin : "com.airbnb.okreplay:gradle-plugin:latest.release", - kotlinPlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlinVersion", - truth : 'com.google.truth:truth:0.40', - robolectric : "org.robolectric:robolectric:3.3.2", - spock : dependencies.create("org.spockframework:spock-core:1.0-groovy-2.4", { + // Build and upload with: + // ./gradlew clean assemble sourcesJar androidSourcesJar javadocsJar androidJavadocsJar uploadArchives --no-daemon --no-parallel + // Need to use snapshot version and explicitly include javadoc/sources tasks until + // https://github.com/vanniktech/gradle-maven-publish-plugin/issues/54 is fixed. + gradleMavenPublishPlugin : 'com.vanniktech:gradle-maven-publish-plugin:0.9.0-SNAPSHOT', + androidPlugin : 'com.android.tools.build:gradle:3.5.0', + groovyPlugin : 'org.codehaus.groovy:groovy-android-gradle-plugin:1.1.0', + nexusPlugin : 'com.bmuschko:gradle-nexus-plugin:2.3.1', + appcompat : "androidx.appcompat:appcompat:$versions.appCompatVersion", + androidXAnnotations : "androidx.annotation:annotation:1.0.1", + groovy : "org.codehaus.groovy:groovy-all:2.4.5:indy", + guava : "com.google.guava:guava:25.0-android", + guava_jre : "com.google.guava:guava:25.0-jre", + ddmlib : 'com.android.tools.ddms:ddmlib:25.3.0', + junit : "junit:junit:4.12", + cglib : "cglib:cglib-nodep:2.2.2", + jsr305 : "com.google.code.findbugs:jsr305:3.0.2", + mockito : 'org.mockito:mockito-core:2.7.13', + okio : 'com.squareup.okio:okio:1.17.2', + okhttp : "com.squareup.okhttp3:okhttp:$versions.okhttpVersion", + mockWebServer : "com.squareup.okhttp3:mockwebserver:$versions.okhttpVersion", + snakeYaml : "org.yaml:snakeyaml:1.16", + kotlinStdLib : "org.jetbrains.kotlin:kotlin-stdlib:$versions.kotlinVersion", + okreplayPlugin : "com.airbnb.okreplay:gradle-plugin:latest.release", + kotlinPlugin : "org.jetbrains.kotlin:kotlin-gradle-plugin:$versions.kotlinVersion", + truth : 'com.google.truth:truth:0.40', + robolectric : "org.robolectric:robolectric:3.3.2", + spock : dependencies.create("org.spockframework:spock-core:1.0-groovy-2.4", { exclude module: "groovy-all" exclude module: "junit" }), - espresso : 'androidx.test.espresso:espresso-core:3.1.0', - androidXTestRunner: 'androidx.test:runner:1.2.0', - androidXTestRules : 'androidx.test:rules:1.1.1' + espresso : 'androidx.test.espresso:espresso-core:3.1.0', + androidXTestRunner : 'androidx.test:runner:1.2.0', + androidXTestRules : 'androidx.test:rules:1.1.1' ] androidConfig = [ diff --git a/gradle/gradle-mvn-push.gradle b/gradle/gradle-mvn-push.gradle deleted file mode 100644 index 64070ec3..00000000 --- a/gradle/gradle-mvn-push.gradle +++ /dev/null @@ -1,229 +0,0 @@ -/* - * Copyright 2013 Chris Banes - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -apply plugin: 'maven' -apply plugin: 'signing' - -version = VERSION_NAME -group = GROUP - -def isReleaseBuild() { - return VERSION_NAME.contains("SNAPSHOT") == false -} - -def getReleaseRepositoryUrl() { - return hasProperty('RELEASE_REPOSITORY_URL') ? RELEASE_REPOSITORY_URL : - "https://oss.sonatype.org/service/local/staging/deploy/maven2/" -} - -def getSnapshotRepositoryUrl() { - return hasProperty('SNAPSHOT_REPOSITORY_URL') ? SNAPSHOT_REPOSITORY_URL : - "https://oss.sonatype.org/content/repositories/snapshots/" -} - -def getRepositoryUsername() { - return hasProperty('NEXUS_USERNAME') ? NEXUS_USERNAME : "" -} - -def getRepositoryPassword() { - return hasProperty('NEXUS_PASSWORD') ? NEXUS_PASSWORD : "" -} - -archivesBaseName = POM_ARTIFACT_ID - -afterEvaluate { project -> - uploadArchives { - repositories { - if (project.hasProperty('NEXUS_USERNAME')) { - mavenDeployer { - beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } - - pom.groupId = GROUP - pom.artifactId = POM_ARTIFACT_ID - pom.version = VERSION_NAME - - repository(url: getReleaseRepositoryUrl()) { - authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) - } - snapshotRepository(url: getSnapshotRepositoryUrl()) { - authentication(userName: getRepositoryUsername(), password: getRepositoryPassword()) - } - - pom.project { - name POM_NAME - packaging POM_PACKAGING - description POM_DESCRIPTION - url POM_URL - - scm { - url POM_SCM_URL - connection POM_SCM_CONNECTION - developerConnection POM_SCM_DEV_CONNECTION - } - - licenses { - license { - name POM_LICENCE_NAME - url POM_LICENCE_URL - distribution POM_LICENCE_DIST - } - } - - developers { - developer { - id POM_DEVELOPER_ID - name POM_DEVELOPER_NAME - } - } - } - } - } else { - mavenInstaller { - pom.groupId = GROUP - pom.artifactId = POM_ARTIFACT_ID - pom.version = VERSION_NAME - } - } - } - } - - signing { - required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") } - sign configurations.archives - } - - if (project.getPlugins().hasPlugin('com.android.application') || - project.getPlugins().hasPlugin('com.android.library')) { - task install(type: Upload, dependsOn: assemble) { - repositories.mavenInstaller { - configuration = configurations.archives - - pom.groupId = GROUP - pom.artifactId = POM_ARTIFACT_ID - pom.version = VERSION_NAME - - pom.project { - name POM_NAME - packaging POM_PACKAGING - description POM_DESCRIPTION - url POM_URL - - scm { - url POM_SCM_URL - connection POM_SCM_CONNECTION - developerConnection POM_SCM_DEV_CONNECTION - } - - licenses { - license { - name POM_LICENCE_NAME - url POM_LICENCE_URL - distribution POM_LICENCE_DIST - } - } - - developers { - developer { - id POM_DEVELOPER_ID - name POM_DEVELOPER_NAME - } - } - } - } - } - - task androidJavadocs(type: Javadoc) { - source = android.sourceSets.main.java.source - excludes = ['**/*.kt'] - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) - } - - task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) { - classifier = 'javadoc' - from androidJavadocs.destinationDir - } - - task androidSourcesJar(type: Jar) { - classifier = 'sources' - from android.sourceSets.main.java.source - } - } else { - install { - repositories.mavenInstaller { - pom.groupId = GROUP - pom.artifactId = POM_ARTIFACT_ID - pom.version = VERSION_NAME - - pom.project { - name POM_NAME - packaging POM_PACKAGING - description POM_DESCRIPTION - url POM_URL - - scm { - url POM_SCM_URL - connection POM_SCM_CONNECTION - developerConnection POM_SCM_DEV_CONNECTION - } - - licenses { - license { - name POM_LICENCE_NAME - url POM_LICENCE_URL - distribution POM_LICENCE_DIST - } - } - - developers { - developer { - id POM_DEVELOPER_ID - name POM_DEVELOPER_NAME - } - } - } - } - } - - task sourcesJar(type: Jar, dependsOn: classes) { - classifier = 'sources' - from sourceSets.main.allSource - } - - task javadocJar(type: Jar, dependsOn: javadoc) { - classifier = 'javadoc' - from javadoc.destinationDir - } - } - - if (JavaVersion.current().isJava8Compatible()) { - allprojects { - tasks.withType(Javadoc) { - options.addStringOption('Xdoclint:none', '-quiet') - } - } - } - - artifacts { - if (project.getPlugins().hasPlugin('com.android.application') || - project.getPlugins().hasPlugin('com.android.library')) { - archives androidSourcesJar - archives androidJavadocsJar - } else { - archives sourcesJar - archives javadocJar - } - } -} \ No newline at end of file diff --git a/okreplay-core/build.gradle b/okreplay-core/build.gradle index e7625188..96bc2e12 100644 --- a/okreplay-core/build.gradle +++ b/okreplay-core/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'java-library' apply plugin: 'org.jetbrains.kotlin.jvm' +apply plugin: 'com.vanniktech.maven.publish' project.group = GROUP project.version = VERSION_NAME @@ -13,5 +14,3 @@ dependencies { implementation dep.okhttp implementation dep.jsr305 } - -apply from: rootProject.file('gradle/gradle-mvn-push.gradle') \ No newline at end of file diff --git a/okreplay-espresso/build.gradle b/okreplay-espresso/build.gradle index 6454304e..1737ad9e 100644 --- a/okreplay-espresso/build.gradle +++ b/okreplay-espresso/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' +apply plugin: 'com.vanniktech.maven.publish' android { compileSdkVersion androidConfig.compileSdkVersion @@ -31,5 +32,3 @@ dependencies { testImplementation dep.truth testImplementation dep.mockito } - -apply from: rootProject.file('gradle/gradle-mvn-push.gradle') diff --git a/okreplay-gradle-plugin/build.gradle b/okreplay-gradle-plugin/build.gradle index 72bb8a78..782ea425 100644 --- a/okreplay-gradle-plugin/build.gradle +++ b/okreplay-gradle-plugin/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'org.jetbrains.kotlin.jvm' apply plugin: 'java-gradle-plugin' +apply plugin: 'com.vanniktech.maven.publish' sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 @@ -25,5 +26,3 @@ test { validateTaskProperties { failOnWarning = true } - -apply from: rootProject.file('gradle/gradle-mvn-push.gradle') diff --git a/okreplay-junit/build.gradle b/okreplay-junit/build.gradle index c951c827..01f4ac24 100644 --- a/okreplay-junit/build.gradle +++ b/okreplay-junit/build.gradle @@ -1,5 +1,6 @@ apply plugin: 'java-library' apply plugin: 'org.jetbrains.kotlin.jvm' +apply plugin: 'com.vanniktech.maven.publish' dependencies { api project(":okreplay-core") @@ -10,5 +11,3 @@ dependencies { sourceCompatibility = "1.7" targetCompatibility = "1.7" - -apply from: rootProject.file('gradle/gradle-mvn-push.gradle') \ No newline at end of file diff --git a/okreplay-noop/build.gradle b/okreplay-noop/build.gradle index 2a4ffd7e..843ec30c 100644 --- a/okreplay-noop/build.gradle +++ b/okreplay-noop/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'java' +apply plugin: 'com.vanniktech.maven.publish' project.group = GROUP project.version = VERSION_NAME @@ -9,5 +10,3 @@ targetCompatibility = "1.7" dependencies { implementation dep.okhttp } - -apply from: rootProject.file('gradle/gradle-mvn-push.gradle') \ No newline at end of file