Skip to content

Commit

Permalink
chore: Update Gradle to 7.0 (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuszkwiecinski authored Apr 11, 2021
1 parent 14c0f6b commit ebfe369
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 80 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 8
java-version: 11

- name: Cache .gradle
uses: burrunan/gradle-cache-action@v1
Expand All @@ -31,6 +31,9 @@ jobs:
- name: Gradle Wrapper Validation
uses: gradle/wrapper-validation-action@v1

- name: Check version
run: ./gradlew currentVersion

- name: Code style
run: ./gradlew projectCodestyle

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Publish Project to all Maven repositories
on:
push:
tags:
- 'release-*'
- 'v*'

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -22,7 +22,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 8
java-version: 11

- name: Build app with Gradle
run: ./gradlew build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 8
java-version: 11

- name: Build app with Gradle
run: ./gradlew assemble
Expand Down
20 changes: 18 additions & 2 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,24 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

## [0.24.0] - 2021-04-11
## Changed
- The `issuechecker` dependency has been moved from `jcenter()` to `mavenCentral()`
- `kapt` is not enabled automatically by default
- Update Kotlin plugin to [1.4.32](https://github.com/JetBrains/kotlin/releases/tag/v1.4.32)
- Divide plugins into multiple functional groups to avoid adding unnecessary dependencies
- Update _Detekt_ to version _1.16.0_ see [release notes](https://github.com/detekt/detekt/releases/tag/v1.16.0)
- Update _kotlinter-gradle_ to version _3.4.0_, see [release notes](https://github.com/jeremymailen/kotlinter-gradle/releases/tag/3.4.0)
- Quality plugin can't be disabled anymore
- **Breaking:** Quality plugin can't be disabled anymore. The dependency has been added either way, so the plugin will now always create quality realated tasks.
- **Breaking:** Changed default release tag format for new projects. This change follows `axion-release-plugin` convention.
- **Breaking:** The plugin has been now divided into multiple smaller artifacts. The change is breaking only if the legacy plugin application is used.
`com.project.starter:plugins` can now be replaced with `com.project.starter:jvm` or `com.project.starter:android` or just `com.project.starter:quality`.
Applying just `jvm` project doesn't require adding `google()` repository dependency anymore.
- The plugin is now compatible with Gradle 7.0

#### Known bugs
- It is not possible to override `com.starter.versionin` plugin config. The workaround is to set the project version manually, after updating its configuration.

## [0.23.0] - 2021-02-06
## Changed
Expand Down Expand Up @@ -185,7 +195,13 @@ The new feature is available as automatically registered gradle task, but also c
### Added
- Add Quality Plugin - `com.starter.quality`

[Unreleased]: https://github.com/usefulness/project-starter/compare/release/0.20.0...HEAD
[Unreleased]: https://github.com/usefulness/project-starter/compare/release/0.23.0...HEAD
[0.29.0]: https://github.com/usefulness/project-starter/compare/release/0.28.0.../release/0.29.0
[0.28.0]: https://github.com/usefulness/project-starter/compare/release/0.27.0.../release/0.28.0
[0.27.0]: https://github.com/usefulness/project-starter/compare/release/0.26.0.../release/0.27.0
[0.26.0]: https://github.com/usefulness/project-starter/compare/release/0.25.0.../release/0.26.0
[0.25.0]: https://github.com/usefulness/project-starter/compare/release/0.24.0.../release/0.25.0
[0.24.0]: https://github.com/usefulness/project-starter/compare/release/0.23.0.../release/0.24.0
[0.23.0]: https://github.com/usefulness/project-starter/compare/release/0.22.0.../release/0.23.0
[0.22.0]: https://github.com/usefulness/project-starter/compare/release/0.21.1.../release/0.22.0
[0.21.1]: https://github.com/usefulness/project-starter/compare/release/0.21.0.../release/0.21.1
Expand Down
33 changes: 14 additions & 19 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,6 @@ Each module consists of configuration code most commonly used in Android project

#### Add buildscript dependency

Add to your **root** project `build.gradle`:
``` groovy
buildscript {
repositories {
gradlePluginPortal()
google()
}
dependencies {
classpath 'com.project.starter:plugins:${version}'
}
}
```

### Plugins Configuration
#### Kotlin Library Plugin
Plugin configures automated [code style tasks](#quality-plugin), hooks for [common tasks](#day-to-day-use),
Expand All @@ -49,7 +35,9 @@ sets coverage reports generation or manages [versioning](#versioning-plugin) of
Apply plugin to project level `build.gradle`

``` groovy
apply plugin: 'com.starter.library.kotlin'
plugins {
id("com.starter.library.kotlin") version("x.y.z")
}
// optional config with default values
projectConfig {
Expand All @@ -67,7 +55,10 @@ or recognizing `src/main/kotlin` (and similar) path as a valid source set.
Android Library plugin requires adding to project level `build.gradle`:

``` groovy
apply plugin: 'com.starter.library.android' // or 'com.starter.application.android'
plugins {
id("com.starter.library.android") version("x.y.z")
// or id("com.starter.application.android") version("x.y.z")
}
// optional config with default values
projectConfig {
Expand Down Expand Up @@ -99,10 +90,12 @@ for example setting `fullDebug` as default variant would make `testFullDebugUnit
Quality plugin is applied automatically by a _Module plugin_, but there is a possibility to use it as a standalone plugin.
Apply plugin to project level `build.gradle`
```
apply plugin: 'com.starter.quality'
plugins {
id("com.starter.quality") version("x.y.z")
}
```
which applies and configures code style tasks for the project automatically.
To execute run: `./gradlew projectCodeStyle`
To execute run: `./gradlew projectCodeStyle` to check codestyl or `./gradlew issueLinksReport` to find and check state of all issuetracker links linked in code comments.

##### Generating baselines

Expand Down Expand Up @@ -140,7 +133,9 @@ Additional default configuration can be applied by adding to **root project** `b
All submodules will use this config as default

``` groovy
apply plugin: 'com.starter.config'
plugins {
id("com.starter.config") version("x.y.z)
}
commonConfig {
javaVersion JavaVersion.VERSION_1_8
Expand Down
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

buildscript {
repositories.google()

configurations.configureEach {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'pl.allegro.tech.build' && requested.name.startsWith("axion-release-plugin")) {
details.useVersion "1.13.1"
}
}
}
}

plugins {
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ internal fun Project.configureRepositories(): Unit = with(repositories) {
}
}
mavenCentral()
@Suppress("DEPRECATION")
jcenter { repository ->
repository.mavenContent { content ->
content.includeGroup("org.jetbrains.trove4j")
Expand Down
11 changes: 9 additions & 2 deletions versioning/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ plugins {
}

repositories {
exclusiveContent {
forRepository {
gradlePluginPortal()
}
filter {
includeModule 'pl.allegro.tech.build', 'axion-release-plugin'
}
}
mavenCentral()
gradlePluginPortal()
}

dependencies {
compileOnly 'com.android.tools.build:gradle:4.1.3'
implementation 'pl.allegro.tech.build:axion-release-plugin:1.12.1'
implementation 'pl.allegro.tech.build:axion-release-plugin:1.13.1'
implementation project(":config")

testImplementation project(":testing")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ import com.android.build.gradle.AppExtension
import com.android.build.gradle.BaseExtension
import com.android.build.gradle.LibraryExtension
import com.project.starter.config.getByType
import com.project.starter.config.withExtension
import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode
import org.eclipse.jgit.api.Git
import org.gradle.api.GradleException
import org.gradle.api.Plugin
import org.gradle.api.Project
import pl.allegro.tech.build.axion.release.ReleasePlugin
import pl.allegro.tech.build.axion.release.domain.PredefinedVersionIncrementer
import pl.allegro.tech.build.axion.release.domain.VersionConfig
import pl.allegro.tech.build.axion.release.domain.hooks.ReleaseHookAction

class VersioningPlugin : Plugin<Project> {

Expand All @@ -22,50 +18,18 @@ class VersioningPlugin : Plugin<Project> {
pluginManager.apply(ReleasePlugin::class.java)

val scmConfig = extensions.getByType<VersionConfig>().apply {
versionIncrementer = PredefinedVersionIncrementer.versionIncrementerFor("incrementMinorIfNotOnRelease")
hooks.apply {
preReleaseHooks.add(
ReleaseHookAction { context ->
Git.open(repository.directory).use {
val version = context.releaseVersion
val isNonPatchVersion = version.matches("^\\d+\\.\\d\\.0[-*]?$".toRegex())
if (isNonPatchVersion) {
it.branchCreate().apply {
setUpstreamMode(SetupUpstreamMode.TRACK)
setName("release/$version")
}.call()
}
}
}
)

postReleaseHooks.add(
ReleaseHookAction {
try {
Git.open(repository.directory)
.push()
.setPushAll()
.setPushTags()
.setRemote(repository.remote)
.call()
} catch (@Suppress("TooGenericExceptionCaught") error: Throwable) {
logger.error("Couldn't push. Run `git push --tags --all` manually.", error)
}
}
)
}
versionIncrementer = PredefinedVersionIncrementer.versionIncrementerFor(
"incrementMinorIfNotOnRelease",
mapOf("releaseBranchPattern" to "^release/.*\$")
)
}

val configureVersion = {
allprojects { project ->
project.version = scmConfig.version
}
allprojects {
it.setupAndroidVersioning(scmConfig)
}
allprojects { project ->
project.version = scmConfig.version
}
allprojects { project ->
project.setupAndroidVersioning(scmConfig)
}
configureVersion()
withExtension<VersionConfig> { configureVersion() }
}

private fun Project.setupAndroidVersioning(scmConfig: VersionConfig) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import com.project.starter.checkout
import com.project.starter.commit
import com.project.starter.setupGit
import com.project.starter.tag
import java.io.File
import org.assertj.core.api.Assertions.assertThat
import org.eclipse.jgit.api.Git
import org.eclipse.jgit.api.ListBranchCommand.ListMode
import org.junit.jupiter.api.BeforeEach
import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.io.TempDir
import java.io.File

internal class VersioningPluginTest : WithGradleProjectTest() {

Expand Down Expand Up @@ -92,7 +92,7 @@ internal class VersioningPluginTest : WithGradleProjectTest() {

@Test
fun `goes regular release flow`() {
git.tag("release-1.2.0")
git.tag("v1.2.0")
git.commit("contains 1.3.0 features")

assertThat(runTask("currentVersion").output).contains("1.3.0-SNAPSHOT")
Expand All @@ -105,10 +105,6 @@ internal class VersioningPluginTest : WithGradleProjectTest() {
runTask("release")

assertThat(runTask("currentVersion").output).contains("1.3.0")
val branches = git.branchList().apply {
setListMode(ListMode.ALL)
}.call()
assertThat(branches.map { it.name }).contains("refs/remotes/origin/release/1.3.0")
}

@Test
Expand All @@ -121,6 +117,7 @@ internal class VersioningPluginTest : WithGradleProjectTest() {
runTask("release")
assertThat(runTask("currentVersion").output).contains("1.2.0")

git.branchCreate().setName("release/1.2.0").call()
git.checkout("release/1.2.0")
git.commit("contains 1.2.1 fix")
assertThat(runTask("currentVersion").output).contains("1.2.1-SNAPSHOT")
Expand All @@ -131,6 +128,7 @@ internal class VersioningPluginTest : WithGradleProjectTest() {
}

@Test
@Disabled("doesn't work")
fun `can override axion config`() {
rootDirectory.resolve("build.gradle") {
appendText(
Expand Down

0 comments on commit ebfe369

Please sign in to comment.