mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
chore: add publication configuration for modules
This commit is contained in:
@@ -45,7 +45,7 @@ android {
|
||||
|
||||
buildTypes { release { isShrinkResources = true } }
|
||||
|
||||
packagingOptions {
|
||||
packaging {
|
||||
resources.excludes.addAll(
|
||||
arrayOf(
|
||||
"META-INF/eclipse.inf",
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -42,5 +42,4 @@ object BuildConfig {
|
||||
|
||||
/** The source and target Java compatibility. */
|
||||
val javaVersion = JavaVersion.VERSION_11
|
||||
val javaVersionMajor = 11
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of AndroidIDE.
|
||||
*
|
||||
* AndroidIDE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* AndroidIDE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import org.gradle.kotlin.dsl.provideDelegate
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Information about the CI build.
|
||||
*
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
object CI {
|
||||
|
||||
/** The short commit hash. */
|
||||
val commitHash by lazy {
|
||||
val sha = System.getenv("GITHUB_SHA") ?: return@lazy ""
|
||||
shortSha(sha)
|
||||
}
|
||||
|
||||
/** Name of the current branch. */
|
||||
val branchName by lazy {
|
||||
System.getenv("GITHUB_REF_NAME") ?: "main" // by default, 'main'
|
||||
}
|
||||
|
||||
/** Whether the current build is a CI build. */
|
||||
val isCiBuild by lazy { "true" == System.getenv("CI") }
|
||||
|
||||
private fun shortSha(sha: String): String {
|
||||
return ProcessBuilder("git", "rev-parse", "--short", sha)
|
||||
.directory(File("."))
|
||||
.redirectErrorStream(true)
|
||||
.start()
|
||||
.inputStream
|
||||
.bufferedReader()
|
||||
.readText()
|
||||
.trim()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* This file is part of AndroidIDE.
|
||||
*
|
||||
* AndroidIDE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* AndroidIDE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
object ProjectConfig {
|
||||
|
||||
/**
|
||||
* The GitHub organization for this project.
|
||||
*/
|
||||
const val GITHUB_ORGANIZATION = "AndroidIDEOfficial"
|
||||
|
||||
/**
|
||||
* The GitHub repsitory for this project.
|
||||
*/
|
||||
const val GITHUB_REPOSITORY = "AndroidIDE"
|
||||
|
||||
/**
|
||||
* The GitHub repository URL for this project.
|
||||
*/
|
||||
const val GITHUB_URL = "https://github.com/${GITHUB_ORGANIZATION}/${GITHUB_REPOSITORY}"
|
||||
|
||||
/**
|
||||
* The Project website.
|
||||
*/
|
||||
const val PROJECT_SITE = "https://androidide.com"
|
||||
|
||||
/**
|
||||
* The GIT SCM URL.
|
||||
*/
|
||||
const val SCM_GIT = "scm:git:git://github.com/${GITHUB_ORGANIZATION}/${GITHUB_REPOSITORY}.git"
|
||||
|
||||
/**
|
||||
* The SSH SCM URL.
|
||||
*/
|
||||
const val SCM_SSH = "scm:git:ssh://git@github.com/${GITHUB_ORGANIZATION}/${GITHUB_REPOSITORY}.git"
|
||||
}
|
||||
+88
-8
@@ -15,8 +15,16 @@
|
||||
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@file:Suppress("UnstableApiUsage")
|
||||
|
||||
import com.android.build.gradle.BaseExtension
|
||||
import com.itsaky.androidide.plugins.AndroidIDEPlugin
|
||||
import com.vanniktech.maven.publish.AndroidSingleVariantLibrary
|
||||
import com.vanniktech.maven.publish.JavaLibrary
|
||||
import com.vanniktech.maven.publish.JavadocJar
|
||||
import com.vanniktech.maven.publish.MavenPublishBaseExtension
|
||||
import com.vanniktech.maven.publish.SonatypeHost.Companion.S01
|
||||
import org.gradle.api.Project
|
||||
|
||||
@Suppress("DSL_SCOPE_VIOLATION")
|
||||
plugins {
|
||||
@@ -24,18 +32,35 @@ plugins {
|
||||
alias(libs.plugins.android.application) apply false
|
||||
alias(libs.plugins.android.library) apply false
|
||||
alias(libs.plugins.kotlin) apply false
|
||||
alias(libs.plugins.maven.publish) apply false
|
||||
alias(libs.plugins.gradle.publish) apply false
|
||||
}
|
||||
|
||||
buildscript { dependencies { classpath("com.google.android.gms:oss-licenses-plugin:0.10.6")
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20")
|
||||
} }
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath("com.google.android.gms:oss-licenses-plugin:0.10.6")
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.20")
|
||||
}
|
||||
}
|
||||
|
||||
val Project.projectVersionCode by lazy {
|
||||
val Project.simpleVersionName: String by lazy {
|
||||
val version = rootProject.version.toString()
|
||||
val regex = Regex("^v\\d+\\.?\\d+\\.?\\d+")
|
||||
val regex = Regex("^v\\d+\\.?\\d+\\.?\\d+-\\w+")
|
||||
|
||||
return@lazy regex.find(version)?.value?.substring(1)?.replace(".", "")?.toInt()?.also {
|
||||
logger.warn("Version code is '$it' (from version ${rootProject.version}).")
|
||||
return@lazy regex.find(version)?.value?.substring(1)?.also {
|
||||
logger.warn("Simple version name is '$it' (from version $version)")
|
||||
}
|
||||
?: throw IllegalStateException(
|
||||
"Invalid version string '$version'. Version names must be SEMVER with 'v' prefix"
|
||||
)
|
||||
}
|
||||
|
||||
val Project.projectVersionCode: Int by lazy {
|
||||
val version = simpleVersionName
|
||||
val regex = Regex("^\\d+\\.?\\d+\\.?\\d+")
|
||||
|
||||
return@lazy regex.find(version)?.value?.replace(".", "")?.toInt()?.also {
|
||||
logger.warn("Version code is '$it' (from version ${version}).")
|
||||
}
|
||||
?: throw IllegalStateException(
|
||||
"Invalid version string '$version'. Version names must be SEMVER with 'v' prefix"
|
||||
@@ -75,7 +100,8 @@ fun Project.configureBaseExtension() {
|
||||
subprojects {
|
||||
apply { plugin(AndroidIDEPlugin::class.java) }
|
||||
|
||||
version = rootProject.version
|
||||
project.group = "com.itsaky.androidide"
|
||||
project.version = rootProject.version
|
||||
plugins.withId("com.android.application") { configureBaseExtension() }
|
||||
plugins.withId("com.android.library") { configureBaseExtension() }
|
||||
|
||||
@@ -86,6 +112,60 @@ subprojects {
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withId("com.vanniktech.maven.publish.base") {
|
||||
configure<MavenPublishBaseExtension> {
|
||||
|
||||
pom {
|
||||
name.set(project.name)
|
||||
description.set(project.description)
|
||||
inceptionYear.set("2021")
|
||||
url.set(ProjectConfig.GITHUB_URL)
|
||||
licenses {
|
||||
license {
|
||||
name.set("The GNU General Public License, v3.0")
|
||||
url.set("https://www.gnu.org/licenses/gpl-3.0.en.html")
|
||||
distribution.set("https://www.gnu.org/licenses/gpl-3.0.en.html")
|
||||
}
|
||||
}
|
||||
|
||||
developers {
|
||||
developer {
|
||||
id.set("androidide")
|
||||
name.set("AndroidIDE")
|
||||
url.set(ProjectConfig.PROJECT_SITE)
|
||||
}
|
||||
}
|
||||
|
||||
scm {
|
||||
url.set(ProjectConfig.GITHUB_URL)
|
||||
connection.set(ProjectConfig.SCM_GIT)
|
||||
developerConnection.set(ProjectConfig.SCM_SSH)
|
||||
}
|
||||
}
|
||||
|
||||
var versionName = project.simpleVersionName
|
||||
if (CI.isCiBuild) {
|
||||
versionName += "-SNAPSHOT"
|
||||
}
|
||||
|
||||
coordinates(project.group.toString(), project.name, versionName)
|
||||
publishToMavenCentral(host = S01)
|
||||
signAllPublications()
|
||||
|
||||
if (plugins.hasPlugin("com.android.library")) {
|
||||
configure(AndroidSingleVariantLibrary())
|
||||
} else if (plugins.hasPlugin("java-library")) {
|
||||
configure(JavaLibrary(javadocJar = JavadocJar.Javadoc()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
plugins.withId("com.gradle.plugin-publish") {
|
||||
configure<GradlePluginDevelopmentExtension> {
|
||||
version = project.simpleVersionName
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
|
||||
kotlinOptions.jvmTarget = BuildConfig.javaVersion.toString()
|
||||
}
|
||||
|
||||
@@ -14,16 +14,24 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
plugins {
|
||||
id("groovy-gradle-plugin")
|
||||
id("java-gradle-plugin")
|
||||
id("org.jetbrains.kotlin.jvm")
|
||||
id("com.gradle.plugin-publish")
|
||||
}
|
||||
|
||||
group = "com.itsaky.androidide"
|
||||
version = "1.0.0"
|
||||
|
||||
gradlePlugin {
|
||||
plugins.create("androidide") {
|
||||
id = "com.itsaky.androidide"
|
||||
implementationClass = "com.itsaky.androidide.gradle.plugin.AndroidIDEPlugin"
|
||||
website.set(ProjectConfig.GITHUB_URL)
|
||||
vcsUrl.set(ProjectConfig.GITHUB_URL)
|
||||
|
||||
plugins {
|
||||
create("gradlePlugin") {
|
||||
id = "com.itsaky.androidide.gradle"
|
||||
implementationClass = "com.itsaky.androidide.gradle.AndroidIDEGradlePlugin"
|
||||
displayName = "AndroidIDE Gradle Plugin"
|
||||
description = "Gradle plugin for projects that are built with AndroidIDE"
|
||||
tags.set(setOf("androidide"))
|
||||
}
|
||||
}
|
||||
}
|
||||
-44
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* This file is part of AndroidIDE.
|
||||
*
|
||||
* AndroidIDE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* AndroidIDE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.itsaky.androidide.gradle.plugin
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
||||
class AndroidIDEPlugin implements Plugin<Project> {
|
||||
|
||||
@Override
|
||||
void apply (Project project) {
|
||||
def manager = project.getPluginManager ()
|
||||
def isApp = manager.hasPlugin ("com.android.application")
|
||||
def isLibrary = manager.hasPlugin ("com.android.library")
|
||||
|
||||
if (!(isApp || isLibrary)) {
|
||||
println "Project " + project.displayName + " does not apply Android's application or library plugin"
|
||||
println "AndroidIDE's Gradle Plugin will not be applied to this project"
|
||||
return
|
||||
}
|
||||
|
||||
if (isApp) {
|
||||
project.afterEvaluate {
|
||||
project.android.sourceSets {
|
||||
main.java.srcDirs += "${System.getenv ("HOME")}/logsender"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This file is part of AndroidIDE.
|
||||
*
|
||||
* AndroidIDE is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* AndroidIDE is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with AndroidIDE. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.itsaky.androidide.gradle
|
||||
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
|
||||
/**
|
||||
* Gradle Plugin for projects built in AndroidIDE.
|
||||
*
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
class AndroidIDEGradlePlugin : Plugin<Project> {
|
||||
|
||||
override fun apply(target: Project) {
|
||||
}
|
||||
}
|
||||
@@ -109,3 +109,5 @@ tooling-slf4j = { module = "org.slf4j:slf4j-api", version = "2.0.7" }
|
||||
android-application = { id = "com.android.application", version.ref = "agp" }
|
||||
android-library = { id = "com.android.library", version.ref = "agp" }
|
||||
kotlin = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
|
||||
maven-publish = { id = "com.vanniktech.maven.publish.base", version = "0.25.1" }
|
||||
gradle-publish = { id = "com.gradle.plugin-publish", version = "1.2.0" }
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
@Suppress("JavaPluginLanguageLevel")
|
||||
plugins {
|
||||
id("java-library")
|
||||
id("com.vanniktech.maven.publish.base")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
plugins {
|
||||
id("com.android.library")
|
||||
id("com.vanniktech.maven.publish.base")
|
||||
}
|
||||
|
||||
android {
|
||||
|
||||
+2
-35
@@ -52,6 +52,7 @@ include(
|
||||
":eventbus",
|
||||
":eventbus-android",
|
||||
":eventbus-events",
|
||||
":gradle-plugin",
|
||||
":lexers",
|
||||
":logger",
|
||||
":logsender-api",
|
||||
@@ -63,7 +64,6 @@ include(
|
||||
":treeview",
|
||||
":uidesigner",
|
||||
":xml-inflater",
|
||||
":gradle-plugin",
|
||||
":lsp:api",
|
||||
":lsp:models",
|
||||
":lsp:java",
|
||||
@@ -94,37 +94,4 @@ include(
|
||||
":subprojects:xml-dom",
|
||||
":subprojects:xml-formatter",
|
||||
":subprojects:xml-utils"
|
||||
)
|
||||
|
||||
/**
|
||||
* Information about the CI build.
|
||||
*
|
||||
* @author Akash Yadav
|
||||
*/
|
||||
object CI {
|
||||
|
||||
/** The short commit hash. */
|
||||
val commitHash by lazy {
|
||||
val sha = System.getenv("GITHUB_SHA") ?: return@lazy ""
|
||||
shortSha(sha)
|
||||
}
|
||||
|
||||
/** Name of the current branch. */
|
||||
val branchName by lazy {
|
||||
System.getenv("GITHUB_REF_NAME") ?: "main" // by default, 'main'
|
||||
}
|
||||
|
||||
/** Whether the current build is a CI build. */
|
||||
val isCiBuild by lazy { "true" == System.getenv("CI") }
|
||||
|
||||
private fun shortSha(sha: String): String {
|
||||
return ProcessBuilder("git", "rev-parse", "--short", sha)
|
||||
.directory(File("."))
|
||||
.redirectErrorStream(true)
|
||||
.start()
|
||||
.inputStream
|
||||
.bufferedReader()
|
||||
.readText()
|
||||
.trim()
|
||||
}
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user