Skip to content

Commit

Permalink
feat: Gradle Upgrade
Browse files Browse the repository at this point in the history
closes #8
  • Loading branch information
vbaidak committed Nov 6, 2024
1 parent a1be3b0 commit 8d05dde
Show file tree
Hide file tree
Showing 14 changed files with 231 additions and 131 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 "version" build.gradle.kts | 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 @@
# 2.4.0

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

# 2.3.0

* [**#7** Unable to find method 'org.jetbrains.kotlin.gradle.internal.KaptTask.setDestinationDir](https://github.com/Scalified/gradle-sourcegen-plugin/issues/7)
Expand Down
47 changes: 12 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,45 @@
# Gradle SourceGen Plugin

[![Build Status](https://github.com/Scalified/gradle-sourcegen-plugin/actions/workflows/gradle.yml/badge.svg)](https://github.com/Scalified/gradle-sourcegen-plugin/actions)
[![Build Status](https://github.com/Scalified/gradle-sourcegen-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/Scalified/gradle-sourcegen-plugin/actions)
[![Gradle Plugin Portal](https://img.shields.io/maven-metadata/v?label=Plugin&metadataUrl=https%3A%2F%2Fplugins.gradle.org%2Fm2%2Fcom%2Fscalified%2Fplugins%2Fgradle%2Fsourcegen%2Fcom.scalified.plugins.gradle.sourcegen.gradle.plugin%2Fmaven-metadata.xml)](https://plugins.gradle.org/plugin/com.scalified.plugins.gradle.sourcegen)

## Description

[Gradle SourceGen Plugin](https://plugins.gradle.org/plugin/com.scalified.plugins.gradle.sourcegen) configures directory for generated sources
[Gradle SourceGen Plugin](https://plugins.gradle.org/plugin/com.scalified.plugins.gradle.sourcegen) configures directory for the generated sources

## Requirements

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

## Changelog

[Changelog](CHANGELOG.md)
* [Gradle 8+](https://gradle.org/)

## Applying

Build script snippet for plugins DSL for Gradle 2.1 and later:

```gradle
```kotlin
plugins {
id "com.scalified.plugins.gradle.sourcegen" version "<version>"
id "com.scalified.plugins.gradle.sourcegen" version "$VERSION"
}
```

Build script snippet for use in older Gradle versions or where dynamic configuration is required:

```gradle
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.scalified.plugins.gradle:sourcegen:<version>"
}
}
apply plugin: "com.scalified.plugins.gradle.sourcegen"
```

## Usage

After applying the plugin, the following takes place:

1. A directory, specified in the **sourcegen.location** property (**src/main/generated** by default) created (if missing)
1. A directory, specified in the `sourcegen.location` property (`src/main/generated` by default) created (if missing)
2. The created directory is configured:
* as an output for annotation processor generated sources
* for clean up during **clean** task
* as marked generated sources root in IntelliJ IDEA (only if it is reside within **src/main**)
* for clean up during `clean` task
* as marked generated sources root in IntelliJ IDEA (only if it is resided within `src/main`)

## Configuration

Currently the following configuration parameters supported (default values are shown):
Currently, the following configuration parameters are supported (default values are shown):

```gradle
```kotlin
sourcegen {
location = 'src/main/generated' // directory for generated source code
location = "src/main/generated" // directory for the generated source code
}
```

If you need more configuration options, you may <a href="mailto:[email protected]?subject=[Gradle SourceGen Plugin]: Proposals And Suggestions">send a request</a> with description
If you need more configuration options, you may <a href="mailto:[email protected]?subject=[Gradle SourceGen Plugin]: Proposals And Suggestions">send a request</a> with the description

## License

Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
allprojects {

group = "com.scalified"
version = "2.3.2"
version = "2.4.0"

repositories {
mavenCentral()
Expand Down
8 changes: 8 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[versions]
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 sourcegen/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,27 @@
*
*/
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 = listOf("source", "generated", "src")
alias(libs.plugins.gradle.publish)
}

gradlePlugin {
plugins {
@Suppress("UnstableApiUsage")
create("SourceGen Plugin") {
id = "com.scalified.plugins.gradle.sourcegen"
displayName = "${project.properties["PROJECT_NAME"]}"
description = "${project.properties["PROJECT_DESCRIPTION"]}"
implementationClass = "com.scalified.plugins.gradle.sourcegen.SourceGenPlugin"
version = project.version
website.set("https://scalified.com/")
vcsUrl.set("${project.properties["PROJECT_URL"]}")
tags.set(listOf("source", "generated", "src"))
}
}
}

dependencies {
compileOnly(kotlin("gradle-plugin"))
compileOnly(libs.kotlin.gradle)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* MIT License
*
* Copyright (c) 2024 Scalified
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/

package com.scalified.plugins.gradle.sourcegen

internal const val SOURCE_GEN = "sourcegen"

internal const val LOCATION = "src/main/generated"
Loading

0 comments on commit 8d05dde

Please sign in to comment.