Skip to content

Commit

Permalink
Merge pull request #2 from RedMadRobot/publish_config
Browse files Browse the repository at this point in the history
New publish config
  • Loading branch information
Roman Choriev authored Sep 5, 2022
2 parents 12ecd1f + 0ee0125 commit a55913c
Show file tree
Hide file tree
Showing 28 changed files with 237 additions and 174 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ gen/
.gradle/
build/

gradle/publish.properties

# Local configuration file (sdk path, etc)
local.properties
gradle.properties

# Proguard folder generated by Eclipse
proguard/
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ maven {
dependencies {
//core модуль панели
implementation 'com.redmadrobot.debug:panel-core:${debug_panel_version}'
debugImplementation 'com.redmadrobot.debug:panel-core:${debug_panel_version}'
}
```

Expand All @@ -55,21 +55,21 @@ dependencies {
```groovy
dependencies {
//Плагин для работы с аккаунтами
implementation 'com.redmadrobot.debug:accounts-plugin:${debug_panel_version}'
debugImplementation 'com.redmadrobot.debug:accounts-plugin:${debug_panel_version}'
//Плагин для работы с серверами
implementation 'com.redmadrobot.debug:servers-plugin:${debug_panel_version}'
debugImplementation 'com.redmadrobot.debug:servers-plugin:${debug_panel_version}'
//Плагин для работы с SharedPreferences
implementation 'com.redmadrobot.debug:app-settings-plugin:${debug_panel_version}'
debugImplementation 'com.redmadrobot.debug:app-settings-plugin:${debug_panel_version}'
//Плагин для работы с Feature Toggle на основе Flipper
implementation 'com.redmadrobot.debug:flipper-plugin:${debug_panel_version}'
debugImplementation 'com.redmadrobot.debug:flipper-plugin:${debug_panel_version}'
//Так же необходимо подключить саму библеотеку flipper
implementation "com.redmadrobot:flipper:${flipper_version}"
debugImplementation "com.redmadrobot:flipper:${flipper_version}"
//Плагин для подмены переменных
implementation 'com.redmadrobot.debug:variable-plugin:${flipper_version}'
debugImplementation 'com.redmadrobot.debug:variable-plugin:${flipper_version}'
}
```
Expand Down
4 changes: 4 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ buildscript {
}

subprojects {

version = getLibVersion()
group = "com.redmadrobot.debug"

repositories {
google()
jcenter()
Expand Down
13 changes: 13 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,16 @@ repositories {
google()
mavenCentral()
}

gradlePlugin {
plugins {
create("PublishPlugin") {
id = "publishPlugin"
implementationClass = "com.redmadrobot.build.PublishPlugin"
}
}
}

dependencies {
implementation("com.android.tools.build:gradle:7.0.0")
}
17 changes: 6 additions & 11 deletions buildSrc/src/main/kotlin/Project.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import org.gradle.api.Project
import org.gradle.kotlin.dsl.provideDelegate
import java.io.File
import java.util.*
Expand All @@ -7,16 +8,6 @@ object Project {
const val TARGET_SDK = 31
const val COMPILE_SDK = 31

private val versionProperties = Properties().apply {
load(File("gradle/version.properties").inputStream())
}

val versionCod: Int = versionProperties.getProperty("version_code").toInt()
val versionName: String = Properties().apply {
load(File("gradle/version.properties").inputStream())
}.getProperty("version_name")


object BuildTypes {
const val release = "release"
}
Expand All @@ -25,4 +16,8 @@ object Project {
const val androidOptimizedRules = "proguard-android-optimize.txt"
const val projectRules = "proguard-rules.pro"
}
}
}

fun Project.getLibVersion(): String = Properties().apply {
load(File("$rootDir/gradle/publish.properties").inputStream())
}.getProperty("lib_version")
127 changes: 127 additions & 0 deletions buildSrc/src/main/kotlin/PublishPlugin.kt
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"))
}
}
}
3 changes: 2 additions & 1 deletion debug-panel-common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ plugins {
kotlin(Plugins.Kotlin.androidPlugin)
kotlin(Plugins.Kotlin.androidExtensions)
kotlin(Plugins.Kotlin.kapt)
id("publishPlugin")
}

apply(from = rootProject.file("gradle/publish.gradle"))
description = "Debug panel common components"

android {

Expand Down
6 changes: 2 additions & 4 deletions debug-panel-common/library.properties
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
5 changes: 3 additions & 2 deletions debug-panel-core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ plugins {
kotlin(Plugins.Kotlin.androidPlugin)
kotlin(Plugins.Kotlin.androidExtensions)
kotlin(Plugins.Kotlin.kapt)
id("publishPlugin")
}

apply(from = rootProject.file("gradle/publish.gradle"))
description = "Debug panel core library"

android {
compileSdk = Project.COMPILE_SDK
Expand Down Expand Up @@ -47,4 +48,4 @@ android {
dependencies {
implementation(project(":debug-panel-common"))
kapt(Dependencies.room.compiler)
}
}
6 changes: 2 additions & 4 deletions debug-panel-core/library.properties
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
3 changes: 2 additions & 1 deletion debug-panel-no-op/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
plugins {
id(Plugins.Android.libraryPlagin)
kotlin(Plugins.Kotlin.androidPlugin)
id("publishPlugin")
}

apply(from = rootProject.file("gradle/publish.gradle"))
description = "Debug panel no-op dependency module"

android {
compileSdk = Project.COMPILE_SDK
Expand Down
6 changes: 2 additions & 4 deletions debug-panel-no-op/library.properties
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
51 changes: 0 additions & 51 deletions gradle/publish.gradle

This file was deleted.

9 changes: 9 additions & 0 deletions gradle/publish.properties
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
21 changes: 0 additions & 21 deletions gradle/version.gradle

This file was deleted.

Loading

0 comments on commit a55913c

Please sign in to comment.