Skip to content

Commit

Permalink
feat: Add Gradle Plugin Portal publication
Browse files Browse the repository at this point in the history
  • Loading branch information
Mateusz Kwieciński authored and mateuszkwiecinski committed Jan 7, 2020
1 parent 8a582a5 commit 3120bf6
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ jobs:
run: ./gradlew build
- name: Publish to Github Package Registry
run: ./gradlew publish -PGH_TOKEN=${{ secrets.GITHUB_TOKEN }} --continue
- name: Publish to Gradle Plugin Portal
run: ./gradlew publishPlugins -Pgradle.publish.key=${{ secrets.gradle_publish_key }} -Pgradle.publish.secret=${{ secrets.gradle_publish_secret }}
19 changes: 7 additions & 12 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ ___

## Motivation

Multimodule projects. Copied code. BuildSrc. Use it in your own setup.
Multi-Module projects. Copied code. BuildSrc. Use it in your own setup.

## Content

Modules + Quality + TODO(~Versioning~) + TODO(~Publishing~)
Modules + Quality + ~Versioning~ + ~Publishing~

### Getting started

Expand All @@ -16,12 +16,7 @@ Modules + Quality + TODO(~Versioning~) + TODO(~Publishing~)
`/buildSrc/build.gradle`:
``` groovy
repositories {
maven {
url = uri("https://maven.pkg.github.com/mateuszkwiecinski/project-starter")
}
mavenContent {
includeGroup("com.project.starter")
}
gradlePluginPortal()
}
dependencies {
implementation 'com.project.starter:plugins:0.2.0'
Expand All @@ -33,14 +28,14 @@ dependencies {
Apply plugin in project level `build.gradle`

``` groovy
apply plugin: 'plugin-library.kotlin'
apply plugin: 'com.starter.library.kotlin'
```

1. Android Application/Library Plugin
- Minimal setup for Android Library requires adding in project level `build.gradle`:
`apply plugin: 'plugin-library.android'`
`apply plugin: 'com.starter.library.android'`
or for Android Application
`apply plugin: 'plugin-application.android'`
`apply plugin: 'com.starter.application.android'`
- Advanced setup
- `javaFilesAllowed` - defines if project can contain java files, `false` by default
- `generateBuildConfig` - defines if `BuildConfig.java` class will be generated, `false` by default
Expand All @@ -49,7 +44,7 @@ dependencies {
- `coverageExclusions` - defines jacoco coverage exclusions for specific module, `[]` by default

``` groovy
apply plugin: 'plugin-library.android' // or 'plugin-application.android'
apply plugin: 'com.starter.library.android' // or 'com.starter.application.android'
libraryConfig {
javaFilesAllowed = false
Expand Down
20 changes: 16 additions & 4 deletions plugins/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id "com.gradle.plugin-publish" version "0.10.1"
id 'java-gradle-plugin'
id 'org.jetbrains.kotlin.jvm' version '1.3.61'
id 'maven-publish'
Expand Down Expand Up @@ -51,22 +52,33 @@ publishing {
}
}
}
pluginBundle {
website = 'https://github.com/mateuszkwiecinski/project-starter/'
vcsUrl = 'https://github.com/mateuszkwiecinski/project-starter/'
description = 'Set of useful plugins that might be useful for Multi-Module Android projects.'
tags = ['android', 'kotlin', 'quickstart', 'codestyle', 'library']
}

gradlePlugin {
plugins {
quality {
id = 'plugin-quality'
id = 'com.starter.quality'
displayName = 'Code Quality Plugin'
implementationClass = 'com.project.starter.quality.plugins.QualityPlugin'
}
kotlinLibrary {
id = 'plugin-library.kotlin'
id = 'com.starter.library.kotlin'
displayName = 'Kotlin Library Plugin'
implementationClass = 'com.project.starter.modules.plugins.KotlinLibraryPlugin'
}
androidLibrary {
id = 'plugin-library.android'
id = 'com.starter.library.android'
displayName = 'Android Library Plugin'
implementationClass = "com.project.starter.modules.plugins.AndroidLibraryPlugin"
}
commonConfig {
id = "plugin-config"
id = "com.starter.config"
displayName = 'Common Configuration Plugin'
implementationClass = 'com.project.starter.config.plugins.CommonSettingsPlugin'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ internal class CommonSettingsPluginTest : WithGradleTest() {
fun `configures common config extension`() {
@Language("groovy") val buildscript = """
plugins {
id('plugin-config')
id('com.starter.config')
}
commonConfig {
Expand All @@ -69,13 +69,13 @@ internal class CommonSettingsPluginTest : WithGradleTest() {
fun `throws exception if not applied to the root project`() {
@Language("groovy") val buildscript = """
plugins {
id('plugin-config')
id('com.starter.config')
}
""".trimIndent()
module1Root.resolve("build.gradle").appendText(buildscript)

val result = runTask("build", shouldFail = true)

assertThat(result.output).contains("Failed to apply plugin [id 'plugin-config']")
assertThat(result.output).contains("Failed to apply plugin [id 'com.starter.config']")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal class AndroidLibraryPluginTest : WithGradleTest() {
mkdirs()
@Language("groovy") val buildScript = """
plugins {
id('plugin-library.android')
id('com.starter.library.android')
}
android {
Expand Down Expand Up @@ -86,7 +86,7 @@ internal class AndroidLibraryPluginTest : WithGradleTest() {
mkdirs()
resolve("build.gradle").writeText("""
plugins {
id('plugin-library.android')
id('com.starter.library.android')
}
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal class KotlinLibraryPluginTest : WithGradleTest() {
mkdirs()
resolve("build.gradle").writeText("""
plugins {
id('plugin-library.kotlin')
id('com.starter.library.kotlin')
}
dependencies {
Expand Down Expand Up @@ -56,7 +56,7 @@ internal class KotlinLibraryPluginTest : WithGradleTest() {
mkdirs()
resolve("build.gradle").writeText("""
plugins {
id('plugin-library.kotlin')
id('com.starter.library.kotlin')
}
dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ internal class ForbidJavaFilesTaskTest : WithGradleTest() {
@Language("groovy")
val buildScript = """
plugins {
id('plugin-library.kotlin')
id('com.starter.library.kotlin')
}
libraryConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ internal class QualityPluginTest : WithGradleTest() {
mkdirs()
resolve("build.gradle").writeText("""
plugins {
id('plugin-quality')
id('com.starter.quality')
id('kotlin')
}
""".trimIndent())
Expand All @@ -47,7 +47,7 @@ internal class QualityPluginTest : WithGradleTest() {
mkdirs()
resolve("build.gradle").writeText("""
plugins {
id('plugin-quality')
id('com.starter.quality')
id('com.android.library')
id('kotlin-android')
}
Expand Down Expand Up @@ -110,7 +110,7 @@ internal class QualityPluginTest : WithGradleTest() {
fun `formatOnCompile option enables failing builds if code style errors found`() {
@Language("groovy") val buildscript = """
plugins {
id('plugin-config')
id('com.starter.config')
}
commonConfig {
Expand Down

0 comments on commit 3120bf6

Please sign in to comment.