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/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/build.gradle b/build.gradle index 8f94bfe7..7fc573af 100644 --- a/build.gradle +++ b/build.gradle @@ -83,31 +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 url = "${params['downloadUrl']}/${group}/${params['moduleName']}/${params['version']}/${params['moduleName']}-${params['version']}.pom" - - 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}" - - return exists + if (!file("publishInfo.json").exists()) { + throw new GradleException("publishInfo.json not found. Check the README for instructions") } - catch (ignored) { - println "Unable to configure incremental publish for ${name}, check your internet connection" - return null + + 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 + } } - } - project.afterEvaluate { libProps.stringPropertyNames() .findAll { name -> name.contains('version') } .each { name -> 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/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 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/version.gradle b/version.gradle index 93257ca9..392efaee 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 { 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