Skip to content

Commit

Permalink
[RFR-412] Downgrade to Gradle 7 again (8 breaks publish)
Browse files Browse the repository at this point in the history
  • Loading branch information
hb0 committed Apr 26, 2023
1 parent 92039ea commit 7c6ff93
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with the Cyface Publish Plugin for Android. If not, see <http://www.gnu.org/licenses/>.
*/
buildscript {
ext.gradle_version = '8.0.0'
ext.gradle_version = '7.4.2' // Major release available but breaks publish [RFR-412]

repositories {
google()
Expand Down
45 changes: 45 additions & 0 deletions src/main/groovy/de.cyface.android-publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,54 @@ project.android.libraryVariants.all { variant ->
from sourceDirs
archiveClassifier.set('sources')
}

// Attempt to define dependency (Gradle 8 requirement), but does not work [RFR-412]
/*def isDebug = variant.getBuildType().name == 'debug'
def isFlavored = !variant.flavorName.isEmpty()
def flavor = variant.flavorName.replace('_', '-')
def isMock = isFlavored && flavor.contains('Mock')
if (!isDebug && !isMock) {
tasks.named("publish${project.name.capitalize()}${variant.name.capitalize()}PublicationToMavenRepository") {
println "dependsOn publish${project.name.capitalize()}${variant.name.capitalize()}PublicationToMavenRepository on ${variant.name}JavadocJar"
dependsOn("${variant.name}JavadocJar")
dependsOn("${variant.name}SourcesJar")
}
tasks.named("publish${project.name.capitalize()}${variant.name.capitalize()}PublicationToMavenLocal") {
println "dependsOn publish${project.name.capitalize()}${variant.name.capitalize()}PublicationToMavenLocal on ${variant.name}JavadocJar"
dependsOn("${variant.name}JavadocJar")
dependsOn("${variant.name}SourcesJar")
}
}*/
}

// This is probably required to run Javadoc and Source creation on each invocation of publish
publish.dependsOn 'assemble'

// Attempt to define dependency for error occurring in Gradle 8 [RFR-412]
/*tasks.withType(PublishToMavenRepository) { task ->
println "task: ${task.name}"
def projectName = "${project.name.capitalize()}"
println "project: ${projectName}"
def match = task.name =~ /^publish($projectName)(.*)PublicationTo(.*)$/
def variantName = "${match[0][2]}" // Release (persistence) or e.g. CyfaceFullRelease
// For some reasons, the publish task is also dependent on the other projectFlavor javadocJar
//def variant = variantName.uncapitalize()
def suffix = variantName.replace("Cyface", "").replace("Movebis", "")
// Persistence
if (suffix == "Release") {
def variant = suffix.uncapitalize()
println "dependsOn ${variant}SourcesJar/JavadocJar"
dependsOn(["${variant}JavadocJar", "${variant}SourcesJar"])
}
// Datacapturing, Synchronization
else {
def variant = "movebis${suffix}"
def variant2 = "cyface${suffix}"
println "dependsOn ${variant}JavadocJar/SourcesJar ${variant2}JavadocJar/SourcesJar"
dependsOn(["${variant}JavadocJar", "${variant}SourcesJar", "${variant2}JavadocJar", "${variant2}SourcesJar"])
}
}*/

publishing {
// Authenticate at the repository
repositories {
Expand Down Expand Up @@ -122,6 +165,8 @@ publishing {
version android.defaultConfig.versionName
artifact(variant.packageLibraryProvider.get().archivePath)
// Put javadoc and sources into jar
println "publish dependency: ${project.name}${variant.name.capitalize()} on ${variant.name}JavadocJar/SourcesJar"
println ""
artifact(tasks.named("${variant.name}JavadocJar"))
artifact(tasks.named("${variant.name}SourcesJar"))
}
Expand Down

0 comments on commit 7c6ff93

Please sign in to comment.