From b604ee8cfddf8003034d4843610660f5b9d782a8 Mon Sep 17 00:00:00 2001 From: Pranav Pandey Date: Sat, 27 Jan 2024 03:57:35 +0530 Subject: [PATCH] Gradle plugin 8.2.1 Gradle wrapper 8.2-bin. Refactor gradle build files. Improve javadoc for maven artifact. --- build.gradle | 13 +++++-- dynamic-utils/build.gradle | 4 ++- dynamic-utils/maven.gradle | 44 +++++++++++++++++------- gradle/wrapper/gradle-wrapper.properties | 2 +- 4 files changed, 47 insertions(+), 16 deletions(-) diff --git a/build.gradle b/build.gradle index 2e70821..d23d4ce 100644 --- a/build.gradle +++ b/build.gradle @@ -27,10 +27,19 @@ buildscript { repositories { mavenCentral() google() + + // Raw R8 releases. + maven { + url("https://storage.googleapis.com/r8-releases/raw") + } } dependencies { - classpath 'com.android.tools.build:gradle:8.0.2' + classpath 'com.android.tools.build:gradle:8.2.1' + + // More info: https://issuetracker.google.com/issues/280659987 + // noinspection GradleDependency, keep R8 version to AGP 8.1.0-beta4. + classpath("com.android.tools:r8:8.1.46") } } @@ -45,7 +54,7 @@ allprojects { } } -task clean(type: Delete) { +tasks.register('clean', Delete) { delete rootProject.buildDir } diff --git a/dynamic-utils/build.gradle b/dynamic-utils/build.gradle index 8512c53..6004e0b 100644 --- a/dynamic-utils/build.gradle +++ b/dynamic-utils/build.gradle @@ -59,7 +59,9 @@ project.afterEvaluate { destinationDir = new File(destinationDir, variant.baseName) source = variant.sourceSets.collect { - it.java.sourceFiles }.inject { m, i -> m + i + it.java.sourceFiles + }.inject { + m, i -> m + i } doFirst { classpath = project.files(variant.javaCompileProvider.get().classpath.files, diff --git a/dynamic-utils/maven.gradle b/dynamic-utils/maven.gradle index e0e8312..0374a93 100644 --- a/dynamic-utils/maven.gradle +++ b/dynamic-utils/maven.gradle @@ -22,28 +22,45 @@ version = mavenVersion // Android libraries if (project.hasProperty("android")) { - task sourcesJar(type: Jar) { + tasks.register('sourcesJar', Jar) { archiveClassifier.set("sources") from android.sourceSets.main.java.srcDirs } - task javadoc(type: Javadoc) { - dependsOn("generateReleaseRFile") + tasks.register('javadoc', Javadoc) { + dependsOn "generateReleaseRFile" + title "${referenceTitle}

${versionDesc}

${mavenVersion}
" + failOnError = false - source = android.sourceSets.main.java.srcDirs - classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) + source = android.sourceSets.main.java.sourceFiles doNotTrackState("Javadoc needs to be generated every time.") - failOnError = false + if (JavaVersion.current().isJava8Compatible()) { + options.addStringOption('Xdoclint:none', '-quiet') + } + + options.memberLevel = JavadocMemberLevel.PROTECTED + exclude "**/R", "**/R.**", "**/R\$**", "**/BuildConfig*" + + options.windowTitle = "${referenceTitle}" + options.links('http://docs.oracle.com/javase/8/docs/api', + 'http://docs.oracle.com/javase/17/docs/api') + options.links('https://developer.android.com/reference') + options.linksOffline('https://developer.android.com/reference', + 'https://developer.android.com/reference/androidx') } } else { // Java libraries - task sourcesJar(type: Jar, dependsOn: classes) { + tasks.register('sourcesJar', Jar) { + dependsOn classes + archiveClassifier.set("sources") from sourceSets.main.allSource } } -task javadocJar(type: Jar, dependsOn: javadoc) { +tasks.register('javadocJar', Jar) { + dependsOn javadoc + archiveClassifier.set("javadoc") from javadoc.destinationDir } @@ -96,7 +113,7 @@ publishing { dependenciesNode = asNode().appendNode('dependencies') } - // Add all that are 'compile' + // Add all that are 'compile' dependencies. configurations.api.allDependencies.each { def dependencyNode = dependenciesNode.appendNode('dependency') dependencyNode.appendNode('groupId', it.group) @@ -117,13 +134,16 @@ signing { } afterEvaluate { project -> - // Fix javadoc generation + // Fix javadoc generation. javadoc.classpath += files(android.libraryVariants.collect { variant -> variant.javaCompileProvider.get().classpath.files }) def pomTask = "generatePomFileForLibraryPublication" + def dependencies = [javadocJar, sourcesJar, assembleRelease, pomTask] - // Convenience task to prepare everything we need for releases - task prepareArtifacts(dependsOn: [javadocJar, sourcesJar, assembleRelease, pomTask]) { } + // Convenience task to prepare everything we need for releases. + tasks.register('prepareArtifacts') { + dependsOn dependencies + } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fe89711..b1535db 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip