Skip to content

Commit

Permalink
#16 Gradle Upgrade
Browse files Browse the repository at this point in the history
closes #16
  • Loading branch information
vbaidak committed Nov 12, 2024
1 parent 1e4c737 commit 75788dc
Show file tree
Hide file tree
Showing 13 changed files with 155 additions and 73 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build

on:
push:
branches-ignore:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v3

- name: Update Gradle Wrapper Script Permissions
run: chmod +x gradlew

- name: Build with Gradle Wrapper
run: ./gradlew clean build --info
20 changes: 0 additions & 20 deletions .github/workflows/gradle.yml

This file was deleted.

61 changes: 61 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Publish

on:
push:
branches:
- master

jobs:
prepare:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set-vars.outputs.version }}
missing: ${{ steps.set-vars.outputs.missing }}
steps:
- name: Checkout
uses: actions/checkout@v4

- id: set-vars
name: Set variables
run: |
version=$(grep "project = " gradle/libs.versions.toml | awk '{ print $3 }' | tr -d \''"\\')
missing=$(if [ "$(git ls-remote origin refs/tags/$version)" ]; then echo false; else echo true; fi)
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "missing=$missing" >> "$GITHUB_OUTPUT"
publish:
needs: prepare
if: needs.prepare.outputs.missing == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 11
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'adopt'

- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v3

- name: Update Gradle Wrapper Script Permissions
run: chmod +x gradlew

- name: Build with Gradle Wrapper
run: ./gradlew clean build --info

- name: Release
uses: ncipollo/release-action@v1
with:
tag: ${{ needs.prepare.outputs.version }}
skipIfReleaseExists: true
allowUpdates: true
makeLatest: latest

- name: Publish Gradle Plugin
run: >
./gradlew publishPlugins --info
-Pgradle.publish.key=${{ secrets.GRADLE_PUBLISH_KEY }}
-Pgradle.publish.secret=${{ secrets.GRADLE_PUBLISH_SECRET }}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 3.0.0

* [#16 Gradle Upgrade](https://github.com/Scalified/gradle-it-plugin/issues/16)

# 2.4.1

* [**#15** Idea SourceSets Missing Main](https://github.com/Scalified/gradle-it-plugin/issues/15)
Expand Down
19 changes: 1 addition & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

## Requirements

* [Gradle 7+](https://gradle.org/)
* [Gradle 8+](https://gradle.org/)

## Changelog

Expand All @@ -25,23 +25,6 @@ plugins {
}
```

Using legacy plugin application (Kotlin):

```kotlin
buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("gradle.plugin.com.scalified.plugins.gradle:it:$version")
}
}

apply(plugin = "com.scalified.plugins.gradle.it")
```

## Usage

After applying the plugin, the following takes place:
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

allprojects {

group = "com.scalified.plugins.gradle"
version = "2.4.1"
group = "com.scalified"
version = rootProject.libs.versions.project.get()

repositories {
mavenCentral()
Expand Down
10 changes: 10 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[versions]
project = "3.0.0"

gradle-publish = "1.3.0"

[plugins]
gradle-publish = { id = "com.gradle.plugin-publish", version.ref = "gradle-publish" }

[libraries]
kotlin-gradle = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin" }
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
38 changes: 25 additions & 13 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +82,12 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +134,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,11 +201,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
17 changes: 7 additions & 10 deletions it/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,23 @@
*/

plugins {
kotlin("jvm") version "1.7.21"
`kotlin-dsl`

id("com.gradle.plugin-publish") version "1.1.0"
}

pluginBundle {
website = "https://scalified.com/"
vcsUrl = "${project.properties["PROJECT_URL"]}"
description = "${project.properties["PROJECT_DESCRIPTION"]}"
tags = setOf("it", "integration test", "test", "integration", "intTest")
alias(libs.plugins.gradle.publish)
}

gradlePlugin {
plugins {
@Suppress("UnstableApiUsage")
create("IT Plugin") {
id = "com.scalified.plugins.gradle.it"
id = "com.scalified.plugins.gradle.sourcegen"
displayName = "${project.properties["PROJECT_NAME"]}"
description = "${project.properties["PROJECT_DESCRIPTION"]}"
implementationClass = "com.scalified.plugins.gradle.it.ItPlugin"
version = project.version
website.set("https://scalified.com/")
vcsUrl.set("${project.properties["PROJECT_URL"]}")
tags.set(setOf("it", "integration test", "test", "integration", "intTest"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ import org.gradle.api.tasks.SourceSetContainer
internal val Project.sourceSets: SourceSetContainer
get() = (this as ExtensionAware).extensions.getByName("sourceSets") as SourceSetContainer

internal fun Project.sourceSet(name: String): SourceSet = project.sourceSets.getByName(name) as SourceSet
internal fun Project.sourceSet(name: String): SourceSet = project.sourceSets.getByName(name)
21 changes: 13 additions & 8 deletions it/src/main/kotlin/com/scalified/plugins/gradle/it/ItTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package com.scalified.plugins.gradle.it

import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.testing.Test

Expand All @@ -39,15 +40,19 @@ internal const val MAX_PARALLEL_FORKS = 4

open class ItTask : Test() {

init {
group = IT_PLUGIN_GROUP
description = IT_PLUGIN_DESCRIPTION
}
init {
group = IT_PLUGIN_GROUP
description = IT_PLUGIN_DESCRIPTION
}

@Input
var srcDir = "src/$IT_PLUGIN_NAME/java"
@Input
var srcDir = "src/$IT_PLUGIN_NAME/java"

@Input
var resourcesDir = "src/$IT_PLUGIN_NAME/resources"
@Input
var resourcesDir = "src/$IT_PLUGIN_NAME/resources"

@Suppress("UnstableApiUsage")
override fun getDryRun(): Property<Boolean> =
project.objects.property(Boolean::class.java).apply { convention(false) }

}

0 comments on commit 75788dc

Please sign in to comment.