Alexey Tsvetkov
4 years ago
committed by
Alexey Tsvetkov
20 changed files with 170 additions and 102 deletions
@ -1,7 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<project version="4"> |
|
||||||
<component name="VcsDirectoryMappings"> |
|
||||||
<mapping directory="" vcs="Git" /> |
|
||||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" /> |
|
||||||
</component> |
|
||||||
</project> |
|
@ -1,5 +0,0 @@ |
|||||||
Jetpack Compose gradle plugin for easy configuration |
|
||||||
|
|
||||||
Environment variables: |
|
||||||
COMPOSE_GRADLE_PLUGIN_VERSION - version of plugin |
|
||||||
COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION - version of Jetpack Compose which will be used when the plugin is applied |
|
@ -1,88 +0,0 @@ |
|||||||
plugins { |
|
||||||
kotlin("jvm") version "1.4.0" |
|
||||||
id("com.gradle.plugin-publish") version "0.10.1" |
|
||||||
id("de.fuerstenau.buildconfig") version "1.1.8" |
|
||||||
id("java-gradle-plugin") |
|
||||||
id("maven-publish") |
|
||||||
} |
|
||||||
|
|
||||||
private object Info { |
|
||||||
const val name = "Jetpack Compose Plugin" |
|
||||||
const val website = "https://jetbrains.org/compose" |
|
||||||
const val description = "Jetpack Compose gradle plugin for easy configuration" |
|
||||||
const val artifactId = "compose-gradle-plugin" |
|
||||||
val composeVersion = System.getenv("COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION") ?: "0.1.0-SNAPSHOT" |
|
||||||
val version = System.getenv("COMPOSE_GRADLE_PLUGIN_VERSION") ?: composeVersion |
|
||||||
} |
|
||||||
|
|
||||||
group = "org.jetbrains.compose" |
|
||||||
version = Info.version |
|
||||||
|
|
||||||
java { |
|
||||||
sourceCompatibility = JavaVersion.VERSION_1_8 |
|
||||||
targetCompatibility = JavaVersion.VERSION_1_8 |
|
||||||
} |
|
||||||
|
|
||||||
repositories { |
|
||||||
maven("https://dl.bintray.com/kotlin/kotlin-dev") |
|
||||||
jcenter() |
|
||||||
mavenLocal() |
|
||||||
} |
|
||||||
|
|
||||||
dependencies { |
|
||||||
implementation(gradleApi()) |
|
||||||
implementation(localGroovy()) |
|
||||||
compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin") |
|
||||||
testImplementation(gradleTestKit()) |
|
||||||
} |
|
||||||
|
|
||||||
buildConfig { |
|
||||||
packageName = "org.jetbrains.compose" |
|
||||||
clsName = "ComposeBuildConfig" |
|
||||||
buildConfigField("String", "composeVersion", Info.composeVersion) |
|
||||||
} |
|
||||||
|
|
||||||
gradlePlugin { |
|
||||||
plugins { |
|
||||||
create("compose") { |
|
||||||
id = "org.jetbrains.compose" |
|
||||||
displayName = Info.name |
|
||||||
description = Info.description |
|
||||||
implementationClass = "org.jetbrains.compose.ComposePlugin" |
|
||||||
version = project.version |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
pluginBundle { |
|
||||||
website = Info.website |
|
||||||
description = Info.description |
|
||||||
} |
|
||||||
|
|
||||||
publishing { |
|
||||||
repositories { |
|
||||||
maven { |
|
||||||
setUrl(System.getenv("COMPOSE_REPO_URL")) |
|
||||||
credentials { |
|
||||||
username = System.getenv("COMPOSE_REPO_USERNAME") |
|
||||||
password = System.getenv("COMPOSE_REPO_KEY") |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
publications { |
|
||||||
create<MavenPublication>("pluginMaven") { |
|
||||||
artifactId = Info.artifactId |
|
||||||
pom { |
|
||||||
name.set(Info.name) |
|
||||||
description.set(Info.description) |
|
||||||
url.set(Info.website) |
|
||||||
licenses { |
|
||||||
license { |
|
||||||
name.set("The Apache License, Version 2.0") |
|
||||||
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,5 @@ |
|||||||
|
Jetpack Compose gradle plugin for easy configuration |
||||||
|
|
||||||
|
Environment variables: |
||||||
|
* `COMPOSE_GRADLE_PLUGIN_VERSION` - version of plugin |
||||||
|
* `COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION` - version of Jetpack Compose used by the plugin |
@ -0,0 +1,83 @@ |
|||||||
|
import com.gradle.publish.PluginBundleExtension |
||||||
|
|
||||||
|
plugins { |
||||||
|
kotlin("jvm") version "1.4.0" apply false |
||||||
|
id("com.gradle.plugin-publish") version "0.10.1" apply false |
||||||
|
id("de.fuerstenau.buildconfig") version "1.1.8" apply false |
||||||
|
} |
||||||
|
|
||||||
|
subprojects { |
||||||
|
group = BuildProperties.group |
||||||
|
version = BuildProperties.version |
||||||
|
|
||||||
|
repositories { |
||||||
|
maven("https://dl.bintray.com/kotlin/kotlin-dev") |
||||||
|
jcenter() |
||||||
|
mavenLocal() |
||||||
|
} |
||||||
|
|
||||||
|
plugins.withId("java") { |
||||||
|
configureIfExists<JavaPluginExtension> { |
||||||
|
sourceCompatibility = JavaVersion.VERSION_1_8 |
||||||
|
targetCompatibility = JavaVersion.VERSION_1_8 |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
plugins.withId("maven-publish") { |
||||||
|
configureIfExists<PublishingExtension> { |
||||||
|
repositories { |
||||||
|
maven("ComposeRepo") { |
||||||
|
setUrl(System.getenv("COMPOSE_REPO_URL")) |
||||||
|
credentials { |
||||||
|
username = System.getenv("COMPOSE_REPO_USERNAME") |
||||||
|
password = System.getenv("COMPOSE_REPO_KEY") |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
afterEvaluate { |
||||||
|
gradlePluginConfig?.let { configureGradlePlugin(it) } |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
fun Project.configureGradlePlugin(config: GradlePluginConfigExtension) { |
||||||
|
// maven publication for plugin |
||||||
|
configureIfExists<PublishingExtension> { |
||||||
|
publications.create<MavenPublication>("gradlePlugin") { |
||||||
|
artifactId = config.artifactId |
||||||
|
pom { |
||||||
|
name.set(config.displayName) |
||||||
|
description.set(config.description) |
||||||
|
url.set(BuildProperties.website) |
||||||
|
licenses { |
||||||
|
license { |
||||||
|
name.set("The Apache License, Version 2.0") |
||||||
|
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// metadata for gradle plugin portal (relates to pluginBundle extension block from com.gradle.plugin-publish) |
||||||
|
configureIfExists<PluginBundleExtension> { |
||||||
|
vcsUrl = BuildProperties.vcs |
||||||
|
website = BuildProperties.website |
||||||
|
description = config.description |
||||||
|
} |
||||||
|
|
||||||
|
// gradle plugin definition (relates to gradlePlugin extension block from java-gradle-plugin) |
||||||
|
configureIfExists<GradlePluginDevelopmentExtension> { |
||||||
|
plugins { |
||||||
|
create("gradlePlugin") { |
||||||
|
id = config.pluginId |
||||||
|
displayName = config.displayName |
||||||
|
description = config.description |
||||||
|
implementationClass = config.implementationClass |
||||||
|
version = project.version |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,12 @@ |
|||||||
|
plugins { |
||||||
|
`kotlin-dsl` |
||||||
|
} |
||||||
|
|
||||||
|
repositories { |
||||||
|
gradlePluginPortal() |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
compileOnly(gradleApi()) |
||||||
|
implementation(kotlin("stdlib")) |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
pluginManagement { |
||||||
|
repositories { |
||||||
|
gradlePluginPortal() |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
// "Global" properties |
||||||
|
object BuildProperties { |
||||||
|
const val name = "Jetpack Compose Plugin" |
||||||
|
const val group = "org.jetbrains.compose" |
||||||
|
const val website = "https://jetbrains.org/compose" |
||||||
|
const val vcs = "https://github.com/JetBrains/compose-jb" |
||||||
|
val composeVersion: String |
||||||
|
get() = System.getenv("COMPOSE_GRADLE_PLUGIN_COMPOSE_VERSION") ?: "0.1.0-SNAPSHOT" |
||||||
|
val version: String |
||||||
|
get() = System.getenv("COMPOSE_GRADLE_PLUGIN_VERSION") ?: composeVersion |
||||||
|
} |
@ -0,0 +1,17 @@ |
|||||||
|
import org.gradle.api.Project |
||||||
|
|
||||||
|
// Plugin-specific properties (also see gradle-plugins/build.gradle.kts) |
||||||
|
open class GradlePluginConfigExtension { |
||||||
|
lateinit var pluginId: String |
||||||
|
lateinit var artifactId: String |
||||||
|
lateinit var implementationClass: String |
||||||
|
lateinit var displayName: String |
||||||
|
lateinit var description: String |
||||||
|
} |
||||||
|
|
||||||
|
val Project.gradlePluginConfig: GradlePluginConfigExtension? |
||||||
|
get() = extensions.findByType(GradlePluginConfigExtension::class.java) |
||||||
|
|
||||||
|
fun Project.gradlePluginConfig(fn: GradlePluginConfigExtension.() -> Unit) { |
||||||
|
extensions.create("gradlePluginConfig", GradlePluginConfigExtension::class.java).apply(fn) |
||||||
|
} |
@ -0,0 +1,5 @@ |
|||||||
|
import org.gradle.api.Project |
||||||
|
|
||||||
|
inline fun <reified T> Project.configureIfExists(fn: T.() -> Unit) { |
||||||
|
extensions.findByType(T::class.java)?.fn() |
||||||
|
} |
@ -0,0 +1,28 @@ |
|||||||
|
plugins { |
||||||
|
kotlin("jvm") |
||||||
|
id("de.fuerstenau.buildconfig") |
||||||
|
id("com.gradle.plugin-publish") |
||||||
|
id("java-gradle-plugin") |
||||||
|
id("maven-publish") |
||||||
|
} |
||||||
|
|
||||||
|
gradlePluginConfig { |
||||||
|
pluginId = "org.jetbrains.compose" |
||||||
|
artifactId = "compose-gradle-plugin" |
||||||
|
displayName = "Jetpack Compose Plugin" |
||||||
|
description = "Jetpack Compose gradle plugin for easy configuration" |
||||||
|
implementationClass = "org.jetbrains.compose.ComposePlugin" |
||||||
|
} |
||||||
|
|
||||||
|
buildConfig { |
||||||
|
packageName = "org.jetbrains.compose" |
||||||
|
clsName = "ComposeBuildConfig" |
||||||
|
buildConfigField("String", "composeVersion", BuildProperties.composeVersion) |
||||||
|
} |
||||||
|
|
||||||
|
dependencies { |
||||||
|
compileOnly(gradleApi()) |
||||||
|
compileOnly(localGroovy()) |
||||||
|
compileOnly("org.jetbrains.kotlin:kotlin-gradle-plugin") |
||||||
|
testImplementation(gradleTestKit()) |
||||||
|
} |
Loading…
Reference in new issue