diff --git a/README.md b/README.md index e4088f7758..c5db97f5a7 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,6 @@ at https://android.googlesource.com/platform/frameworks/support. * `examples` - examples of multiplatform Compose applications for Desktop and Android * `imageviewer` - Image Viewer application for Android and Desktop * `issues` - GitHub issue tracker with an adaptive UI and ktor-client - * `gradle-plugin` - plugin for simpler usage of Compose with Gradle build + * `gradle-plugins` - plugins, simplifying usage of Compose with Gradle * `templates` - new application templates (see `desktop-template/build_and_run_from_cli_example.sh` for using without Gradle) * `tutorials` - tutorials on using Compose for Desktop diff --git a/gradle-plugin/.idea/vcs.xml b/gradle-plugin/.idea/vcs.xml deleted file mode 100644 index 62bd7a01e9..0000000000 --- a/gradle-plugin/.idea/vcs.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/gradle-plugin/README.md b/gradle-plugin/README.md deleted file mode 100644 index 0cfb1ac96e..0000000000 --- a/gradle-plugin/README.md +++ /dev/null @@ -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 \ No newline at end of file diff --git a/gradle-plugin/build.gradle.kts b/gradle-plugin/build.gradle.kts deleted file mode 100644 index 6866c3e7ca..0000000000 --- a/gradle-plugin/build.gradle.kts +++ /dev/null @@ -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("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") - } - } - } - } - } -} \ No newline at end of file diff --git a/gradle-plugin/.gitignore b/gradle-plugins/.gitignore similarity index 100% rename from gradle-plugin/.gitignore rename to gradle-plugins/.gitignore diff --git a/gradle-plugins/README.md b/gradle-plugins/README.md new file mode 100644 index 0000000000..1252177667 --- /dev/null +++ b/gradle-plugins/README.md @@ -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 \ No newline at end of file diff --git a/gradle-plugins/build.gradle.kts b/gradle-plugins/build.gradle.kts new file mode 100644 index 0000000000..5ae9da02f8 --- /dev/null +++ b/gradle-plugins/build.gradle.kts @@ -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 { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 + } + } + + plugins.withId("maven-publish") { + configureIfExists { + 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 { + publications.create("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 { + vcsUrl = BuildProperties.vcs + website = BuildProperties.website + description = config.description + } + + // gradle plugin definition (relates to gradlePlugin extension block from java-gradle-plugin) + configureIfExists { + plugins { + create("gradlePlugin") { + id = config.pluginId + displayName = config.displayName + description = config.description + implementationClass = config.implementationClass + version = project.version + } + } + } +} diff --git a/gradle-plugins/buildSrc/build.gradle.kts b/gradle-plugins/buildSrc/build.gradle.kts new file mode 100644 index 0000000000..5afd954c56 --- /dev/null +++ b/gradle-plugins/buildSrc/build.gradle.kts @@ -0,0 +1,12 @@ +plugins { + `kotlin-dsl` +} + +repositories { + gradlePluginPortal() +} + +dependencies { + compileOnly(gradleApi()) + implementation(kotlin("stdlib")) +} diff --git a/gradle-plugins/buildSrc/settings.gradle.kts b/gradle-plugins/buildSrc/settings.gradle.kts new file mode 100644 index 0000000000..c665ff9667 --- /dev/null +++ b/gradle-plugins/buildSrc/settings.gradle.kts @@ -0,0 +1,5 @@ +pluginManagement { + repositories { + gradlePluginPortal() + } +} diff --git a/gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt b/gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt new file mode 100644 index 0000000000..2838b029f9 --- /dev/null +++ b/gradle-plugins/buildSrc/src/main/kotlin/BuildProperties.kt @@ -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 +} diff --git a/gradle-plugins/buildSrc/src/main/kotlin/GradlePluginConfigExtension.kt b/gradle-plugins/buildSrc/src/main/kotlin/GradlePluginConfigExtension.kt new file mode 100644 index 0000000000..36ab740085 --- /dev/null +++ b/gradle-plugins/buildSrc/src/main/kotlin/GradlePluginConfigExtension.kt @@ -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) +} diff --git a/gradle-plugins/buildSrc/src/main/kotlin/gradleUtils.kt b/gradle-plugins/buildSrc/src/main/kotlin/gradleUtils.kt new file mode 100644 index 0000000000..2643b4db3f --- /dev/null +++ b/gradle-plugins/buildSrc/src/main/kotlin/gradleUtils.kt @@ -0,0 +1,5 @@ +import org.gradle.api.Project + +inline fun Project.configureIfExists(fn: T.() -> Unit) { + extensions.findByType(T::class.java)?.fn() +} \ No newline at end of file diff --git a/gradle-plugins/compose/build.gradle.kts b/gradle-plugins/compose/build.gradle.kts new file mode 100644 index 0000000000..3df0af2518 --- /dev/null +++ b/gradle-plugins/compose/build.gradle.kts @@ -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()) +} diff --git a/gradle-plugin/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt b/gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt similarity index 100% rename from gradle-plugin/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt rename to gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/ComposePlugin.kt diff --git a/gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.jetbrains.compose.properties b/gradle-plugins/compose/src/main/resources/META-INF/gradle-plugins/org.jetbrains.compose.properties similarity index 100% rename from gradle-plugin/src/main/resources/META-INF/gradle-plugins/org.jetbrains.compose.properties rename to gradle-plugins/compose/src/main/resources/META-INF/gradle-plugins/org.jetbrains.compose.properties diff --git a/gradle-plugin/gradle/wrapper/gradle-wrapper.jar b/gradle-plugins/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from gradle-plugin/gradle/wrapper/gradle-wrapper.jar rename to gradle-plugins/gradle/wrapper/gradle-wrapper.jar diff --git a/gradle-plugin/gradle/wrapper/gradle-wrapper.properties b/gradle-plugins/gradle/wrapper/gradle-wrapper.properties similarity index 100% rename from gradle-plugin/gradle/wrapper/gradle-wrapper.properties rename to gradle-plugins/gradle/wrapper/gradle-wrapper.properties diff --git a/gradle-plugin/gradlew b/gradle-plugins/gradlew similarity index 100% rename from gradle-plugin/gradlew rename to gradle-plugins/gradlew diff --git a/gradle-plugin/gradlew.bat b/gradle-plugins/gradlew.bat similarity index 100% rename from gradle-plugin/gradlew.bat rename to gradle-plugins/gradlew.bat diff --git a/gradle-plugin/settings.gradle.kts b/gradle-plugins/settings.gradle.kts similarity index 85% rename from gradle-plugin/settings.gradle.kts rename to gradle-plugins/settings.gradle.kts index 4021da4f7b..198979339b 100644 --- a/gradle-plugin/settings.gradle.kts +++ b/gradle-plugins/settings.gradle.kts @@ -3,4 +3,6 @@ pluginManagement { gradlePluginPortal() maven("https://dl.bintray.com/kotlin/kotlin-dev") } -} \ No newline at end of file +} + +include(":compose") \ No newline at end of file