Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
Adopt org.openrewrite.build.recipe-library (#12)
Browse files Browse the repository at this point in the history
* Adopt org.openrewrite.build.recipe-library

* Bump Gradle wrapper version

* Use rewrite-recipe-bom and add rewrite-terraform
  • Loading branch information
timtebeek authored Jun 12, 2023
1 parent 3bf7e07 commit 33779fa
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 216 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/moderne-ingest.yml

This file was deleted.

204 changes: 18 additions & 186 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,201 +1,33 @@
import nebula.plugin.contacts.Contact
import nebula.plugin.contacts.ContactsExtension
import nl.javadude.gradle.plugins.license.LicenseExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.util.*

buildscript {
repositories {
gradlePluginPortal()
}
}

plugins {
`java-library`
`maven-publish`
signing

id("org.jetbrains.kotlin.jvm") version "1.6.21"
id("nebula.maven-resolved-dependencies") version "17.3.2"
id("nebula.release") version "15.3.1"
id("io.github.gradle-nexus.publish-plugin") version "1.0.0"

id("com.github.hierynomus.license") version "0.16.1"
id("com.github.jk1.dependency-license-report") version "1.16"
id("org.owasp.dependencycheck") version "7.0.4.1"

id("nebula.maven-publish") version "17.3.2"
id("nebula.contacts") version "5.1.0"
id("nebula.info") version "9.3.0"

id("nebula.javadoc-jar") version "17.3.2"
id("nebula.source-jar") version "17.3.2"
id("nebula.maven-apache-license") version "17.3.2"

id("org.openrewrite.rewrite") version "latest.release"
}

rewrite {
activeRecipe("org.openrewrite.java.format.AutoFormat", "org.openrewrite.staticanalysis.CodeCleanup")
}

apply(plugin = "nebula.publish-verification")

configure<nebula.plugin.release.git.base.ReleasePluginExtension> {
defaultVersionStrategy = nebula.plugin.release.NetflixOssStrategies.SNAPSHOT(project)
}

dependencyCheck {
analyzers.assemblyEnabled = false
suppressionFile = "suppressions.xml"
failBuildOnCVSS = 9.0F
id("org.openrewrite.build.recipe-library") version "latest.release"
}

group = "org.openrewrite.recipe"
description =
"A rewrite module hosting recommended collections of recipes"
description = "A rewrite module hosting recommended collections of recipes"

repositories {
if(!project.hasProperty("releasing")) {
mavenLocal()
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
val maven = maven {
url = uri("https://repo.gradle.org/gradle/libs-releases/")
content {
excludeVersionByRegex(".+", ".+", ".+-rc-?[0-9]*")
}
}
mavenCentral()
}

nexusPublishing {
repositories {
sonatype()
// Needed to pick up snapshot versions of rewrite
maven {
url = uri("https://oss.sonatype.org/content/repositories/snapshots/")
}
}

signing {
setRequired({
!project.version.toString().endsWith("SNAPSHOT") || project.hasProperty("forceSigning")
})
val signingKey: String? by project
val signingPassword: String? by project
useInMemoryPgpKeys(signingKey, signingPassword)
sign(publishing.publications["nebula"])
}

configurations.all {
resolutionStrategy {
cacheChangingModulesFor(0, TimeUnit.SECONDS)
cacheDynamicVersionsFor(0, TimeUnit.SECONDS)
}
}

var rewriteVersion = if(project.hasProperty("releasing")) {
"latest.release"
} else {
"latest.integration"
}

val rewriteVersion = rewriteRecipe.rewriteVersion.get()
dependencies {
constraints {
implementation("com.fasterxml.woodstox:woodstox-core:6.5.1") {
because("Versions <= 6.3.1")
}
}

implementation("org.openrewrite:rewrite-yaml:$rewriteVersion")
implementation("org.openrewrite:rewrite-java:${rewriteVersion}")
implementation("org.openrewrite:rewrite-xml:${rewriteVersion}")
implementation("org.openrewrite:rewrite-hcl:${rewriteVersion}")
implementation("org.openrewrite:rewrite-maven:${rewriteVersion}")
implementation("org.openrewrite.recipe:rewrite-static-analysis:${rewriteVersion}")

runtimeOnly("com.fasterxml.jackson.core:jackson-core:2.15.1")

compileOnly("org.projectlombok:lombok:latest.release")
annotationProcessor("org.projectlombok:lombok:latest.release")

testImplementation("org.jetbrains.kotlin:kotlin-reflect")
testImplementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.openrewrite:rewrite-test:$rewriteVersion")
testImplementation("org.assertj:assertj-core:latest.release")
testImplementation("org.junit.jupiter:junit-jupiter-api:latest.release")
testImplementation("org.junit.jupiter:junit-jupiter-params:latest.release")
testImplementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
testImplementation("org.jetbrains.kotlin:kotlin-reflect")

testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:latest.release")
}

tasks.withType(KotlinCompile::class.java).configureEach {
kotlinOptions {
jvmTarget = "1.8"
}
}

tasks.named<Test>("test") {
useJUnitPlatform()
jvmArgs = listOf("-Xmx1g", "-XX:+UnlockDiagnosticVMOptions", "-XX:+ShowHiddenFrames")
}

tasks.named<JavaCompile>("compileJava") {
sourceCompatibility = JavaVersion.VERSION_1_8.toString()
targetCompatibility = JavaVersion.VERSION_1_8.toString()
implementation(platform("org.openrewrite.recipe:rewrite-recipe-bom:$rewriteVersion"))

options.isFork = true
options.compilerArgs.addAll(listOf("--release", "8"))
}

configure<ContactsExtension> {
val j = Contact("[email protected]")
j.moniker("Moderne")

people["[email protected]"] = j
}

configure<LicenseExtension> {
ext.set("year", Calendar.getInstance().get(Calendar.YEAR))
skipExistingHeaders = true
header = project.rootProject.file("gradle/licenseHeader.txt")
mapping(mapOf("kt" to "SLASHSTAR_STYLE", "java" to "SLASHSTAR_STYLE"))
strictCheck = true
}

configure<PublishingExtension> {
publications {
named("nebula", MavenPublication::class.java) {
suppressPomMetadataWarningsFor("runtimeElements")

pom.withXml {
(asElement().getElementsByTagName("dependencies").item(0) as? org.w3c.dom.Element)?.let { dependencies ->
dependencies.getElementsByTagName("dependency").let { dependencyList ->
var i = 0
var length = dependencyList.length
while (i < length) {
(dependencyList.item(i) as? org.w3c.dom.Element)?.let { dependency ->
if ((dependency.getElementsByTagName("scope")
.item(0) as? org.w3c.dom.Element)?.textContent == "provided"
) {
dependencies.removeChild(dependency)
i--
length--
}
}
i++
}
}
}
}
}
}
}

tasks.withType<Javadoc> {
// assertTrue(boolean condition) -> assertThat(condition).isTrue()
// warning - invalid usage of tag >
// see also: https://blog.joda.org/2014/02/turning-off-doclint-in-jdk-8-javadoc.html
(options as StandardJavadocDocletOptions).addStringOption("Xdoclint:none", "-quiet")
}
implementation("org.openrewrite:rewrite-yaml")
implementation("org.openrewrite:rewrite-java")
implementation("org.openrewrite:rewrite-xml")
implementation("org.openrewrite:rewrite-hcl")
implementation("org.openrewrite:rewrite-maven")
implementation("org.openrewrite.recipe:rewrite-terraform")
implementation("org.openrewrite.recipe:rewrite-static-analysis")

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
options.compilerArgs.add("-parameters")
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
18 changes: 14 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,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/subprojects/plugins/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,10 +80,10 @@ 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##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# 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"'
Expand Down Expand Up @@ -143,12 +143,16 @@ fi
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=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=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -205,6 +209,12 @@ set -- \
org.gradle.wrapper.GradleWrapperMain \
"$@"

# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi

# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
Expand Down
15 changes: 9 additions & 6 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
@rem limitations under the License.
@rem

@if "%DEBUG%" == "" @echo off
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
Expand All @@ -25,7 +25,8 @@
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

Expand All @@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Expand Down Expand Up @@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
if %ERRORLEVEL% equ 0 goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%

:mainEnd
if "%OS%"=="Windows_NT" endlocal
Expand Down

0 comments on commit 33779fa

Please sign in to comment.