-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from RedMadRobot/publish_config
New publish config
- Loading branch information
Showing
28 changed files
with
237 additions
and
174 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
package com.redmadrobot.build | ||
|
||
import com.android.build.gradle.BaseExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.api.publish.PublishingExtension | ||
import org.gradle.api.publish.maven.MavenPublication | ||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin | ||
import org.gradle.jvm.tasks.Jar | ||
import org.gradle.kotlin.dsl.* | ||
import org.gradle.plugins.signing.SigningExtension | ||
import org.gradle.plugins.signing.SigningPlugin | ||
import java.io.File | ||
import java.util.* | ||
|
||
class PublishPlugin : Plugin<Project> { | ||
lateinit var projectDir: File | ||
lateinit var rootDir: File | ||
|
||
private val publishProperties by lazy { | ||
|
||
Properties().apply { | ||
load(File("$rootDir/gradle/publish.properties").inputStream()) | ||
} | ||
} | ||
|
||
private val libraryProperties by lazy { | ||
Properties().apply { | ||
load(File("$projectDir/library.properties").inputStream()) | ||
} | ||
} | ||
|
||
override fun apply(target: Project) { | ||
projectDir = target.projectDir | ||
rootDir = target.rootDir | ||
|
||
with(target) { | ||
afterEvaluate { | ||
configurePublishing() | ||
configureSigning() | ||
} | ||
} | ||
} | ||
|
||
private fun Project.configurePublishing() { | ||
plugins.apply(MavenPublishPlugin::class.java) | ||
val libDescription = this.description.orEmpty() | ||
|
||
configure<PublishingExtension> { | ||
val android = extensions.getByName<BaseExtension>("android") | ||
|
||
val sourcesJar = tasks.register<Jar>("sourcesJar") { | ||
archiveClassifier.set("sources") | ||
from(android.sourceSets["main"].java.srcDirs) | ||
} | ||
|
||
publications { | ||
create("release", MavenPublication::class.java) { | ||
from(project.components.findByName("release")) | ||
|
||
artifact(sourcesJar) | ||
|
||
groupId = publishProperties.getProperty("group_id") | ||
artifactId = libraryProperties.getProperty("lib_name") | ||
version = publishProperties.getProperty("lib_version") | ||
|
||
pom { | ||
name.set(libraryProperties.getProperty("lib_name")) | ||
description.set(libDescription) | ||
url.set(publishProperties.getProperty("home_page")) | ||
|
||
licenses { | ||
license { | ||
name.set(publishProperties.getProperty("license_name")) | ||
url.set(publishProperties.getProperty("license_url")) | ||
} | ||
} | ||
|
||
developers { | ||
developer { | ||
id.set("Zestxx") | ||
name.set("Roman Choriev") | ||
email.set("[email protected]") | ||
} | ||
|
||
developer { | ||
id.set("osipxd") | ||
name.set("Osip Fatkullin") | ||
email.set("[email protected]") | ||
} | ||
} | ||
|
||
scm { | ||
connection.set("scm:git:git://github.com/RedMadRobot/debug-panel-android.git") | ||
developerConnection.set("scm:git:ssh://github.com/RedMadRobot/debug-panel-android.git") | ||
url.set(publishProperties.getProperty("home_page")) | ||
} | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
maven { | ||
name = "OSSRH" | ||
url = project.uri(publishProperties.getProperty("sonatype_repo")) | ||
|
||
credentials { | ||
username = System.getenv("OSSRH_USER") | ||
password = System.getenv("OSSRH_PASSWORD") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private fun Project.configureSigning() { | ||
plugins.apply(SigningPlugin::class.java) | ||
|
||
configure<SigningExtension> { | ||
val publishing = extensions.getByType(PublishingExtension::class.java) | ||
|
||
useGpgCmd() | ||
sign(publishing.publications.getByName("release")) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
lib_version=0.5.0 | ||
lib_name=panel-common | ||
group_id=com.redmadrobot.debug | ||
repository=https://nexus.redmadrobot.com/repository/android/ | ||
artifact_location=/outputs/aar/debug-panel-common-release.aar | ||
lib_vcs=https://github.com/RedMadRobot/debug-panel-android.git | ||
lib_issue_tracker=https://github.com/RedMadRobot/debug-panel-android/issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
lib_version=0.5.0 | ||
lib_name=panel-core | ||
group_id=com.redmadrobot.debug | ||
repository=https://nexus.redmadrobot.com/repository/android/ | ||
artifact_location=/outputs/aar/debug-panel-core-release.aar | ||
lib_vcs=https://github.com/RedMadRobot/debug-panel-android.git | ||
lib_issue_tracker=https://github.com/RedMadRobot/debug-panel-android/issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
lib_version=0.5.0 | ||
lib_name=panel-no-op | ||
group_id=com.redmadrobot.debug | ||
repository=https://nexus.redmadrobot.com/repository/android/ | ||
artifact_location=/outputs/aar/debug-panel-no-op-release.aar | ||
lib_vcs=https://github.com/RedMadRobot/debug-panel-android.git | ||
lib_issue_tracker=https://github.com/RedMadRobot/debug-panel-android/issues |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
home_page=https://github.com/RedMadRobot/debug-panel-android | ||
group_id=com.redmadrobot.debug | ||
|
||
sonatype_repo=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2 | ||
|
||
license_name=MIT License | ||
license_url=http://opensource.org/licenses/MIT | ||
|
||
lib_version=0.7.4 |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.