From 1536c2aedd9a462f02a70b467b0c8b93206cff3b Mon Sep 17 00:00:00 2001 From: Kevin Block Date: Wed, 26 Feb 2025 20:08:29 -0500 Subject: [PATCH 1/5] Update publishing script --- .gitignore | 1 + androidLib.gradle | 11 +++++++++-- build.gradle | 34 +++++++++++++++++++++++----------- version.gradle | 4 +++- 4 files changed, 36 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 347e252e..10b4f10a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ build/ # Local configuration file (sdk path, etc) local.properties +publishInfo.json # Log/OS Files *.log diff --git a/androidLib.gradle b/androidLib.gradle index be1f1aeb..619d20fc 100644 --- a/androidLib.gradle +++ b/androidLib.gradle @@ -30,12 +30,11 @@ android { compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 - // Reduce META-INF file conflicts - kotlinOptions.freeCompilerArgs += ['-module-name', "${parent.ext.groupId}.${project.getName()}"] } kotlinOptions { jvmTarget = '1.8' + freeCompilerArgs += ['-module-name', "${parent.ext.groupId}.${project.getName()}"] } libraryVariants.all { variant -> @@ -103,6 +102,14 @@ afterEvaluate { } } + tasks.withType(GenerateModuleMetadata).configureEach { + dependsOn("bundleReleaseAar") + } + + tasks.matching { task -> task.name.startsWith('publish') }.configureEach { publishTask -> + publishTask.dependsOn("bundleReleaseAar") + } + signing { if (parent.ext.publishInfo['signArtifacts']) { def signingKey = parent.ext.publishInfo['signingKey'] diff --git a/build.gradle b/build.gradle index 8f94bfe7..61f62b5d 100644 --- a/build.gradle +++ b/build.gradle @@ -89,20 +89,32 @@ task incrementalPublish { def artifactExists = { params -> // githubUrl, moduleName, version, true def group = libProps['groupId'].replace(".", "/") - def url = "${params['downloadUrl']}/${group}/${params['moduleName']}/${params['version']}/${params['moduleName']}-${params['version']}.pom" + def moduleName = params['moduleName'] + def version = params['version'] - try { - HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection() - connection.setRequestProperty("Authorization", params['auth']) - connection.connect() - - def exists = connection.getResponseCode() == HttpURLConnection.HTTP_OK - println "pom for ${params['moduleName']} exists on $url}: ${exists}" + def url = "${params['downloadUrl']}/${group}/${moduleName}/${version}/${moduleName}-${version}" + def fileTypes = ['aar', 'pom'] - return exists + try { + // Check AAR AND POM + for (String fileType : fileTypes) { + def urlWithType = "${url}.${fileType}" + HttpURLConnection connection = (HttpURLConnection) new URL(urlWithType).openConnection() + connection.setRequestProperty("Authorization", params['auth']) + connection.setRequestMethod("HEAD") + connection.connect() + def exists = connection.getResponseCode() == HttpURLConnection.HTTP_OK + + println "Artifact check for ${moduleName}-${version}: ${fileType} exists: ${exists}" + + if (exists) { + return true + } + } + return false } - catch (ignored) { - println "Unable to configure incremental publish for ${name}, check your internet connection" + catch (exception) { + println "Unable to configure incremental publish ${exception}" return null } } diff --git a/version.gradle b/version.gradle index 93257ca9..2a3c89d8 100644 --- a/version.gradle +++ b/version.gradle @@ -1,7 +1,9 @@ allprojects { def versionKey = project.name + "_version" + def versionSuffix = parent.ext.publishInfo['versionSuffix'] group = parent.ext.libProps['groupId'] - version = parent.ext.libProps[versionKey] + parent.ext.versionSuffix + def suffix = versionSuffix.isEmpty() ? "" : "-" + versionSuffix + version = parent.ext.libProps[versionKey] + suffix task printProjectVersion { doLast { From b7fa0528ef14ef079be8c02885d58eb1f23dc587 Mon Sep 17 00:00:00 2001 From: Kevin Block Date: Wed, 26 Feb 2025 20:08:45 -0500 Subject: [PATCH 2/5] Bump navigation version --- libraryVersion.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraryVersion.properties b/libraryVersion.properties index d724db03..230e9cc3 100755 --- a/libraryVersion.properties +++ b/libraryVersion.properties @@ -6,7 +6,7 @@ view_version=1.2.0 material_version=1.0.4 functions_version=1.0.0 savedstate_version=1.0.1 -navigation_version=1.2.1 +navigation_version=1.2.2 recyclerview_version=1.2.0 viewpager2_version=1.0.0 communications_version=1.0.0 From 825ceab377909dfbc48cdf1cae961eec603bb3d2 Mon Sep 17 00:00:00 2001 From: Kevin Block Date: Thu, 27 Feb 2025 07:42:10 -0500 Subject: [PATCH 3/5] Cleanup warnings --- app/build.gradle | 2 -- communications/build.gradle | 1 - constraintlayout/build.gradle | 2 -- core/build.gradle | 2 -- material/build.gradle | 2 -- recyclerview/build.gradle | 2 -- test/build.gradle | 2 -- view/build.gradle | 2 -- 8 files changed, 15 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c3bf82ee..a133f58d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -67,9 +67,7 @@ android { } dependencies { - testImplementation 'junit:junit:4.13.2' - implementation fileTree(dir: 'libs', include: ['*.jar']) debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.7' diff --git a/communications/build.gradle b/communications/build.gradle index ddbda4ce..a47f12d7 100644 --- a/communications/build.gradle +++ b/communications/build.gradle @@ -1,7 +1,6 @@ apply from: "${project.rootDir}/androidLib.gradle" dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) implementation parent.ext.appCompat implementation parent.ext.supportAnnotations diff --git a/constraintlayout/build.gradle b/constraintlayout/build.gradle index 92c160f2..dd96a3e6 100644 --- a/constraintlayout/build.gradle +++ b/constraintlayout/build.gradle @@ -1,8 +1,6 @@ apply from: "${project.rootDir}/androidLib.gradle" dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation parent.ext.kotlin implementation parent.ext.ktxCore implementation parent.ext.appCompat diff --git a/core/build.gradle b/core/build.gradle index 5677d367..963e4f7f 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -7,8 +7,6 @@ android { } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation parent.ext.kotlin implementation parent.ext.ktxCore implementation parent.ext.appCompat diff --git a/material/build.gradle b/material/build.gradle index 9708408f..da1c750e 100644 --- a/material/build.gradle +++ b/material/build.gradle @@ -1,8 +1,6 @@ apply from: "${project.rootDir}/androidLib.gradle" dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation parent.ext.kotlin implementation parent.ext.ktxCore implementation parent.ext.material diff --git a/recyclerview/build.gradle b/recyclerview/build.gradle index d94633bf..98182e14 100644 --- a/recyclerview/build.gradle +++ b/recyclerview/build.gradle @@ -12,8 +12,6 @@ android { } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation parent.ext.kotlin implementation parent.ext.ktxCore implementation parent.ext.appCompat diff --git a/test/build.gradle b/test/build.gradle index c6e62037..025e48be 100644 --- a/test/build.gradle +++ b/test/build.gradle @@ -1,8 +1,6 @@ apply from: "${project.rootDir}/androidLib.gradle" dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation parent.ext.kotlin implementation parent.ext.appCompat implementation parent.ext.recyclerView diff --git a/view/build.gradle b/view/build.gradle index 16951821..15228cbb 100644 --- a/view/build.gradle +++ b/view/build.gradle @@ -8,8 +8,6 @@ android { } dependencies { - implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation parent.ext.kotlin implementation parent.ext.ktxCore implementation parent.ext.appCompat From 48ea52784c96e21d3c99441b9ea44a6d40ed2ad0 Mon Sep 17 00:00:00 2001 From: Kevin Block Date: Thu, 27 Feb 2025 07:42:25 -0500 Subject: [PATCH 4/5] Fix CI error --- version.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.gradle b/version.gradle index 2a3c89d8..392efaee 100644 --- a/version.gradle +++ b/version.gradle @@ -1,6 +1,6 @@ allprojects { def versionKey = project.name + "_version" - def versionSuffix = parent.ext.publishInfo['versionSuffix'] + def versionSuffix = parent.ext.publishInfo?.versionSuffix ?: "" group = parent.ext.libProps['groupId'] def suffix = versionSuffix.isEmpty() ? "" : "-" + versionSuffix version = parent.ext.libProps[versionKey] + suffix From 4331bf401428858eaecedb083906a3848ce24368 Mon Sep 17 00:00:00 2001 From: Kevin Block Date: Thu, 27 Feb 2025 07:42:44 -0500 Subject: [PATCH 5/5] Warn the user if they don't have a json file for publishing --- build.gradle | 68 +++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/build.gradle b/build.gradle index 61f62b5d..7fc573af 100644 --- a/build.gradle +++ b/build.gradle @@ -83,43 +83,47 @@ allprojects { } } +project.afterEvaluate { + tasks.register('incrementalPublish') { -task incrementalPublish { - def libProps = project.ext.libProps - def artifactExists = { params -> - // githubUrl, moduleName, version, true - def group = libProps['groupId'].replace(".", "/") - def moduleName = params['moduleName'] - def version = params['version'] - - def url = "${params['downloadUrl']}/${group}/${moduleName}/${version}/${moduleName}-${version}" - def fileTypes = ['aar', 'pom'] - - try { - // Check AAR AND POM - for (String fileType : fileTypes) { - def urlWithType = "${url}.${fileType}" - HttpURLConnection connection = (HttpURLConnection) new URL(urlWithType).openConnection() - connection.setRequestProperty("Authorization", params['auth']) - connection.setRequestMethod("HEAD") - connection.connect() - def exists = connection.getResponseCode() == HttpURLConnection.HTTP_OK - - println "Artifact check for ${moduleName}-${version}: ${fileType} exists: ${exists}" - - if (exists) { - return true + if (!file("publishInfo.json").exists()) { + throw new GradleException("publishInfo.json not found. Check the README for instructions") + } + + def libProps = project.ext.libProps + def artifactExists = { params -> + // githubUrl, moduleName, version, true + def group = libProps['groupId'].replace(".", "/") + def moduleName = params['moduleName'] + def version = params['version'] + + def url = "${params['downloadUrl']}/${group}/${moduleName}/${version}/${moduleName}-${version}" + def fileTypes = ['aar', 'pom'] + + try { + // Check AAR AND POM + for (String fileType : fileTypes) { + def urlWithType = "${url}.${fileType}" + HttpURLConnection connection = (HttpURLConnection) new URL(urlWithType).openConnection() + connection.setRequestProperty("Authorization", params['auth']) + connection.setRequestMethod("HEAD") + connection.connect() + def exists = connection.getResponseCode() == HttpURLConnection.HTTP_OK + + println "Artifact check for ${moduleName}-${version}: ${fileType} exists: ${exists}" + + if (exists) { + return true + } } + return false + } + catch (exception) { + println "Unable to configure incremental publish ${exception}" + return null } - return false - } - catch (exception) { - println "Unable to configure incremental publish ${exception}" - return null } - } - project.afterEvaluate { libProps.stringPropertyNames() .findAll { name -> name.contains('version') } .each { name ->