Skip to content

Commit

Permalink
Release 0.13 (#198)
Browse files Browse the repository at this point in the history
* Improve documentation on snapshots
* Add compatibility table
* Remove unused function, `"task" in project.tasks.names` is equivalent and better.
* Update changelog
  • Loading branch information
TWiStErRob committed Dec 20, 2021
1 parent 9b70d7f commit 8922ae1
Show file tree
Hide file tree
Showing 8 changed files with 139 additions and 93 deletions.
27 changes: 17 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
# Change Log

## 0.13 *(2021-11-01 --- )*
## 0.13 *(2021-11-01 --- 2021-12-20)*

### Breaking
* ...
* convention: Removed `autoVersion` DSL, it's automatically deciding whether it needs auto-versioning. (#174)
* convention: Removed `addRunTasks` DSL, using lazy task creations instead. (#189)
* Some internal moves and renames of classes. (#177, #184, #195/#197)
* Lazy/up-to-date improvements (#11/#186/#189, #194/#196)

### New
* Gradle 7 compatible (up to 7.3) (#163)
* Gradle 7 compatible (up to 7.3) (#163)
* quality: Android Gradle Plugin 7.0.3 compatible (#180)
(still uses some deprecated code)
* New compatibility modules for compile-time checks for old code. (#181)
* quality: `validateViolations` and `violationCountFile` tasks (#195/#197)

### Fixes
* ...

### Deprecations

#### `net.twisterrob.gradle:artifact-name`
* ...
* convention: `-dump` option is not supported by R8 (#175/#179)
* Kotlin, Java, resources are published in -sources.jar (#187/#192)
* convention: Fail fast on release (#188/#191)

### Internal
* ...
* Test improvements (#162, #176, #193)
* Build improvements (#166, #167, #146/#168, #171, #173, #178, #182)
* convention: plugin is split into multiple pieces. (#173)
* Code cleanup (#170, #184, #11/#186/#189)


## 0.12 *(2021-06-06 --- 2021-11-01)*
Expand Down
92 changes: 86 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,106 @@ For details on what was changed in different versions, see [CHANGELOG](CHANGELOG

## Compatibility

Android Gradle Plugin 3.1.4 — 4.2.2 on Gradle 4.9 — 6.9 as listed in [AGP's compatibility guide](https://developer.android.com/studio/releases/gradle-plugin#updating-gradle).

Gradle 4.4 — 4.9 is not supported, because it's hard to backport the lazy task configuration APIs.

Convention plugins only support Android Gradle Plugin 4.0.0 — 4.2.2 on Gradle 6.1.1+, because it's really hard to backport all the features to 3.x with no need for this.
Android Gradle Plugin 3.1.4 — 7.0.x on Gradle 4.9 — 7.3.x as listed in [AGP's compatibility guide](https://developer.android.com/studio/releases/gradle-plugin#updating-gradle).

| AGP →<br/>Gradle ↓ | 3.1.x | 3.2.x | 3.3.x | 3.4.x | 3.5.x | 3.6.x | 4.0.x | 4.1.x | 4.2.x | 7.0.x | 7.1.x | 7.2.x |
|:-------------------|:---------:|:-------:|:-------:|:-------:|:--------:|:--------:|:--------:|:--------:|:--------:|:--------:|:-----:|:-----:|
| 4.4 - 4.8.1 | 0.5 - 0.7 | ^1 |||||||||||
| 4.9 - 4.10 | 0.8 - ∞ | 0.7 - ∞ |||||||||||
| 4.10.1 - 5.1 || 0.8 - ∞ | 0.8 - ∞ ||||||||||
| 5.1.1 - 5.4 ||| 0.9 - ∞ | 0.9 - ∞ |||||||||
| 5.4.1 - 5.6.3 |||| 0.9 - ∞ | sup. ||||||||
| 5.6.4 ||||| 0.10 - ∞ | 0.10 - ∞ |||||||
| 6.0 - 6.1 ||||| 0.11 - ∞ | 0.11 - ∞ |||||||
| 6.1.1 - 6.4.1 ||||| 0.11 - ∞ | 0.11 - ∞ | 0.11 - ∞ ||||||
| 6.5 - 6.7 ||||| 0.11 - ∞ | 0.11 - ∞ | 0.11 - ∞ | 0.11 - ∞ |||||
| 6.7.1 - 6.9.1 |||||||| 0.11 - ∞ | 0.11 - ∞ ||||
| 7.0 - 7.3.2 ||||||||| 0.13 - ∞ | 0.13 - ∞ | N/A | N/A |

* ❓ = not sure if it's supported by AGP, never tested.
* ❌ = incompatible based on AGP compatibility.
* sup. = supported based on AGP compatibility, but not tested.
* N/A = not available yet
* ∞ = latest version
* ^1 = Gradle 4.4 — 4.9 is not supported, because it's hard to backport the lazy task configuration APIs.
* ^2 = Convention plugins only support Android Gradle Plugin 4.0.0 — 4.2.2 on Gradle 6.1.1+, because it's really hard to backport all the features to 3.x with no need for this.

## Quick setup
There are different ways to use a Gradle plugin, choose your poison below.
<details>
<summary>normal build.gradle(.kts) (<code>buildscript</code>)</summary>

```gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("net.twisterrob.gradle:twister-quality:${VERSION_TWISTER_QUALITY}")
classpath("net.twisterrob.gradle:twister-quality:x.y")
}
}
// Kotlin
apply(plugin = "net.twisterrob.quality")
// Groovy
apply plugin: "net.twisterrob.quality"
```

</details>

<details>
<summary>buildSrc classpath</summary>

#### `buildSrc/build.gradle(.kts)`

```gradle
repositories {
mavenCentral()
}
dependencies {
implementation("net.twisterrob.gradle:twister-quality:x.y")
}
```

#### `build.gradle(.kts)`

```gradle
// Kotlin
apply(plugin = "net.twisterrob.quality")
// Groovy
apply plugin: "net.twisterrob.quality"
```

</details>

<details>
<summary><code>plugins</code> block and settings.gradle(.kts)</summary>

See it live at [SNAPSHOT example](docs/examples/snapshot/settings.gradle.kts).

```gradle
plugins {
id("net.twisterrob.quality") version "x.y"
}
```

```gradle
pluginManagement {
repositories {
mavenCentral()
}
resolutionStrategy {
eachPlugin {
when (requested.id.id) {
"net.twisterrob.quality" ->
useModule("net.twisterrob.gradle:twister-quality:${requested.version}")
}
}
}
}
```

</details>

For more, see the [examples](docs/examples) folder.

## Features
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,8 @@
package net.twisterrob.gradle.dsl

import org.gradle.api.Project
import org.gradle.api.UnknownTaskException
import org.gradle.api.reporting.ReportingExtension
import org.gradle.api.tasks.TaskContainer
import org.gradle.kotlin.dsl.getByName

val Project.reporting: ReportingExtension
get() = this.extensions.getByName<ReportingExtension>(ReportingExtension.NAME)

operator fun TaskContainer.contains(name: String): Boolean =
try {
this.named(name)
true
} catch (ex: UnknownTaskException) {
false
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
package net.twisterrob.gradle.dsl

import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.UnknownDomainObjectException
import org.gradle.api.UnknownTaskException
import org.gradle.api.plugins.ExtensionContainer
import org.gradle.api.reporting.ReportingExtension
import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.TaskProvider
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertSame
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
import org.junit.jupiter.api.assertThrows
import org.mockito.kotlin.mock
Expand Down Expand Up @@ -66,57 +60,4 @@ class ProjectExtensionsKtTest {
verify(mockExtensions).getByName("reporting")
verifyNoMoreInteractions(mockProject, mockExtensions)
}

@Test fun `TaskContainer contains extension function returns true if task exists`() {
val mockTasks: TaskContainer = mock()
val mockTask: TaskProvider<Task> = mock()
whenever(mockTasks.named("task")).thenReturn(mockTask)

val actual = mockTasks.contains("task")

assertTrue(actual)
verify(mockTasks).named("task")
verifyNoInteractions(mockTask)
verifyNoMoreInteractions(mockTasks)
}

@Test fun `TaskContainer contains extension function can be used as operator`() {
val mockTasks: TaskContainer = mock()
val mockTask: TaskProvider<Task> = mock()
whenever(mockTasks.named("task")).thenReturn(mockTask)

val actual = "task" in mockTasks

assertTrue(actual)
verify(mockTasks).named("task")
verifyNoInteractions(mockTask)
verifyNoMoreInteractions(mockTasks)
}

@Test fun `TaskContainer contains extension function returns false if task does not exist`() {
val mockTasks: TaskContainer = mock()
val mockTask: TaskProvider<Task> = mock()
whenever(mockTasks.named("task")).thenThrow(UnknownTaskException("test"))

val actual = mockTasks.contains("task")

assertFalse(actual)
verify(mockTasks).named("task")
verifyNoInteractions(mockTask)
verifyNoMoreInteractions(mockTasks)
}

@Test fun `TaskContainer contains extension function propagates other errors`() {
val mockTasks: TaskContainer = mock()
val mockTask: TaskProvider<Task> = mock()
whenever(mockTasks.named("task")).thenThrow(UnknownDomainObjectException("test"))

assertThrows<UnknownDomainObjectException> {
mockTasks.contains("task")
}

verify(mockTasks).named("task")
verifyNoInteractions(mockTask)
verifyNoMoreInteractions(mockTasks)
}
}
36 changes: 32 additions & 4 deletions docs/development.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,30 @@ See [test/README.md](../test/README.md).
### Running tests from IDE
See [test/README.md](../test/README.md).


### Using the `-SNAPSHOT` from Sonatype
Every commit that's built on CI is deployed to Sonatype. The version is either in `x.y-SNAPSHOT` or `x.y.branch-SNAPSHOT` form.

The two main entry points are:
* [twister-convention-plugins](https://s01.oss.sonatype.org/service/local/repositories/snapshots/content/net/twisterrob/gradle/twister-convention-plugins/)
* [twister-quality](https://s01.oss.sonatype.org/service/local/repositories/snapshots/content/net/twisterrob/gradle/twister-quality/)

To use the `-SNAPSHOT` builds it's necessary to declare the Sonatype repository:
```gradle
// `repositories { }` in build.gradle > buildscript, or settings.gradle > pluginManagement, or buildSrc > build.gradle
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
name = "Sonatype 01: SNAPSHOTs"
content {
includeGroup("net.twisterrob.gradle")
}
mavenContent {
snapshotsOnly()
}
}
```
and then business as usual, see [README.md](../README.md#quick-setup).


### Using the `-SNAPSHOT` from a local repo
It's possible to deploy a snapshot into the current user's `.m2` folder.
This is useful for testing on external local projects.
Expand All @@ -32,21 +56,23 @@ gradlew publishToMavenLocal
```

#### Consume
```
```gradle
buildscript {
repositories {
mavenLocal() // make sure it's first
}
}
```
and then business as usual (`buildscript { dependencies { classpath "..."` etc. see README.md).
and then business as usual (e.g. `buildscript { dependencies { classpath "..."` etc. see [README.md](../README.md#quick-setup)).


## Using the `-SNAPSHOT` from a local build
This bypasses Gradle's dependency management and uses jars directly. The drawback is that each transitive dependency has to be manually added.

Add in root `build.gradle`:
```groovy
<details>
<summary>Add <code>buildscript</code> block in root `build.gradle`</summary>

```gradle
buildscript {
repositories {
mavenCentral()
Expand Down Expand Up @@ -76,6 +102,8 @@ buildscript {
}
}
```
</details>

To try it out, add `printViolationCounts` from README.md and run `gradlew checkstyleEach :printViolationCounts`.


Expand Down
3 changes: 2 additions & 1 deletion docs/release.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
## Publish release `x.y`

1. `git add gradle.properties CHANGELOG.md & git commit -m "Release x.y"`
1. `git add gradle.properties CHANGELOG.md README.md & git commit -m "Release x.y"`
* `CHANGELOG.md`: review bullet points of what changed
* `CHANGELOG.md`: add links to PRs/commits for changes
* `CHANGELOG.md`: remove empty sections
* `CHANGELOG.md`: update version end date
* `gradle.properties`: remove `-SNAPSHOT` suffix
Double-check that version is `x.y`
* `README.md`: review compatibility table
1. [Draft a new release](https://github.com/TWiStErRob/net.twisterrob.gradle/releases/new) on GitHub
* "_Tag version_": `vx.y` @ Target: `master`
* "_Release title_": `x.y Two Word Summary` (e.g. biggest change / reason for release)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ org.gradle.deprecation.trace=true
# After adding :compat it needs more than 1G, so bumped to 2G.
org.gradle.jvmargs=-Dfile.encoding=UTF-8 -Xmx2G

projectVersion=0.13-SNAPSHOT
projectVersion=0.13

# Default test substitutions
net.twisterrob.test.android.compileSdkVersion=android-30
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package net.twisterrob.gradle.quality

import net.twisterrob.gradle.common.BasePlugin
import net.twisterrob.gradle.common.registerTask
import net.twisterrob.gradle.dsl.contains
import net.twisterrob.gradle.quality.tasks.GlobalLintGlobalFinalizerTask
import org.gradle.api.Project

Expand All @@ -11,7 +10,7 @@ internal open class LintPlugin : BasePlugin() {
override fun apply(target: Project) {
super.apply(target)

if ("lint" !in project.tasks) {
if ("lint" !in project.tasks.names) {
project.registerTask("lint", GlobalLintGlobalFinalizerTask.Creator())
}
}
Expand Down

0 comments on commit 8922ae1

Please sign in to comment.