Skip to content

Commit

Permalink
Migrate to maven-publish plugin as maven plugin has been deprecated.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 683560507
Change-Id: I96f5e317e9bb90c4b659900ea322e718ada6b672
  • Loading branch information
Play Games Services Team authored and copybara-github committed Oct 8, 2024
1 parent cfaab30 commit b12f73f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 40 deletions.
68 changes: 29 additions & 39 deletions SupportFiles/Public/PlayGamesPluginSupport/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ allprojects {
}
}

apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.android.library'

group 'com.google.games'
Expand Down Expand Up @@ -52,53 +52,43 @@ android {
compileSdkVersion 28
}

// Rename the .aar file to be .srcaar to work around
// // having the local repo in a subdirectory in a Unity project.
// // The jar resolver plugin handles the changing back from .srcaar
// // to .aar
// //
// // This is done in 2 parts, first declare the .srcaar as an
// // artifact, the second is a task to rename the aar -> srcaar.
//
artifacts {
archives file("build/${baseName}-${version}.srcaar")
}


task renameLibrary() {
doFirst {
copy {
from "${buildDir}/outputs/aar/${baseName}-release.aar"
into "${buildDir}"
rename {
String fn ->
return fn.replace("release.aar", "${version}.srcaar")
}
// Rename the .aar file to be .srcaar to work around having the local repo in a
// subdirectory in a Unity project.
// The jar resolver plugin handles the changing back from .srcaarto .aar
task renameLibrary(type: Copy) {
from "${buildDir}/outputs/aar/${baseName}-release.aar"
into "${buildDir}"
rename { String fn ->
fn.replace("release.aar", "${version}.srcaar")
}
}


doLast {
configurations.archives.with {
artifacts.remove artifacts.find { it.extension == "aar"}
}
}
}

tasks.whenTaskAdded { task ->
if (task.name == 'assembleRelease')
renameLibrary.dependsOn task
if (task.name == 'assembleRelease') {
renameLibrary.dependsOn(task)
}
}

uploadArchives {
dependsOn renameLibrary
repositories {
mavenDeployer {
repository(url: uri(project.ext.uploadDir))
publishing {
publications {
release(MavenPublication) {
groupId = project.group
artifactId = project.ext.baseName
version = project.version

artifact("${buildDir}/${baseName}-${version}.srcaar" as File)
}
}

repositories {
maven {
url uri(project.ext.uploadDir)
}
}
}
}

tasks.withType(PublishToMavenRepository) { it.dependsOn renameLibrary }

dependencies {
implementation 'com.google.android.gms:play-services-games-v2:17.0.0'
implementation 'com.google.android.gms:play-services-nearby:18.5.0'
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ task build_java_support_lib(type: GradleBuild) {
startParameter.projectProperties.put('projVersion',currentPluginVersion)
startParameter.projectProperties.put('uploadDir', "${project.ext.buildPath}/m2repository")

tasks = ['build', 'uploadArchives']
tasks = ['build', 'publish']
}

build_java_support_lib.ext.remoteTaskPhase = 'prebuild'
Expand Down

0 comments on commit b12f73f

Please sign in to comment.