From cb131ac41c724c5a90e714805503472efa9fedd3 Mon Sep 17 00:00:00 2001 From: Matt Raible Date: Wed, 20 Mar 2024 23:36:25 -0600 Subject: [PATCH] Add templates for plugins for Gradle --- .../__snapshots__/generator.spec.js.snap | 6 ++ ...ipster.code-quality-conventions.gradle.ejs | 81 +++++++++++++++++++ .../jhipster.docker-conventions.gradle.ejs | 53 ++++++++++++ 3 files changed, 140 insertions(+) create mode 100644 generators/quarkus/templates/buildSrc/src/main/groovy/jhipster.code-quality-conventions.gradle.ejs create mode 100644 generators/quarkus/templates/buildSrc/src/main/groovy/jhipster.docker-conventions.gradle.ejs diff --git a/generators/quarkus/__snapshots__/generator.spec.js.snap b/generators/quarkus/__snapshots__/generator.spec.js.snap index 0b332e9d..72e02f1e 100644 --- a/generators/quarkus/__snapshots__/generator.spec.js.snap +++ b/generators/quarkus/__snapshots__/generator.spec.js.snap @@ -430,6 +430,12 @@ exports[`SubGenerator quarkus of quarkus JHipster blueprint > run with oauth2 an "buildSrc/gradle/libs.versions.toml": { "stateCleared": "modified", }, + "buildSrc/src/main/groovy/jhipster.code-quality-conventions.gradle": { + "stateCleared": "modified", + }, + "buildSrc/src/main/groovy/jhipster.docker-conventions.gradle": { + "stateCleared": "modified", + }, "checkstyle.xml": { "stateCleared": "modified", }, diff --git a/generators/quarkus/templates/buildSrc/src/main/groovy/jhipster.code-quality-conventions.gradle.ejs b/generators/quarkus/templates/buildSrc/src/main/groovy/jhipster.code-quality-conventions.gradle.ejs new file mode 100644 index 00000000..35d0859d --- /dev/null +++ b/generators/quarkus/templates/buildSrc/src/main/groovy/jhipster.code-quality-conventions.gradle.ejs @@ -0,0 +1,81 @@ +<%# + Copyright 2013-2024 the original author or authors from the JHipster project. + + This file is part of the JHipster project, see https://www.jhipster.tech/ + for more information. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +-%> +plugins { + id "jacoco" + id "org.sonarqube" + id "com.diffplug.spotless" + id "com.github.andygoossens.gradle-modernizer-plugin" + id "io.spring.nohttp" +} + +jacoco { + toolVersion = "${libs.versions.jacoco.get()}" +} + +jacocoTestReport { + executionData tasks.withType(Test) + classDirectories.from = files(sourceSets.main.output.classesDirs) + sourceDirectories.from = files(sourceSets.main.java.srcDirs) + + reports { + xml.required = true + } +} + +file("sonar-project.properties").withReader { + Properties sonarProperties = new Properties() + sonarProperties.load(it) + + sonarProperties.each { key, value -> + sonarqube { + properties { + property key, value + } + } + } +} + +spotless { + java { + target 'src/*/java/**/*.java' + // removeUnusedImports() + } +} + +modernizer { + failOnViolations = true + includeTestClasses = true +} + +checkstyle { + toolVersion "${libs.versions.checkstyle.get()}" + configFile file("checkstyle.xml") + checkstyleTest.enabled = false +} + +nohttp { + source.include "build.gradle", "README.md" +} + +// workaround for https://github.com/checkstyle/checkstyle/issues/14123 +configurations.checkstyle { + resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") { + select("com.google.guava:guava:0") + } +} \ No newline at end of file diff --git a/generators/quarkus/templates/buildSrc/src/main/groovy/jhipster.docker-conventions.gradle.ejs b/generators/quarkus/templates/buildSrc/src/main/groovy/jhipster.docker-conventions.gradle.ejs new file mode 100644 index 00000000..87530f15 --- /dev/null +++ b/generators/quarkus/templates/buildSrc/src/main/groovy/jhipster.docker-conventions.gradle.ejs @@ -0,0 +1,53 @@ +<%# + Copyright 2013-2024 the original author or authors from the JHipster project. + + This file is part of the JHipster project, see https://www.jhipster.tech/ + for more information. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +-%> +plugins { + id "com.google.cloud.tools.jib" +} + +jib { + from { + image = "<%- dockerContainers.javaJre %>" + platforms { + platform { + architecture = "${findProperty('jibArchitecture') ?: 'amd64'}" + os = "linux" + } + } + } + to { + image = "<%= baseName.toLowerCase() %>:latest" + } + container { + entrypoint = ["bash", "-c", "/entrypoint.sh"] + ports = ["<%= serverPort %>"<% if (cacheProviderHazelcast) { %>, "5701/udp" <% } %>] + environment = [ +<%_ if (cacheProviderInfinispan) { _%> + JAVA_OPTS: "-Djgroups.tcp.address=NON_LOOPBACK -Djava.net.preferIPv4Stack=true", +<%_ } _%> + SPRING_OUTPUT_ANSI_ENABLED: "ALWAYS", + JHIPSTER_SLEEP: "0" + ] + creationTime = "USE_CURRENT_TIMESTAMP" + user = 1000 + } + extraDirectories { + paths = file("<%= dockerServicesDir %>jib") + permissions = ["/entrypoint.sh": "755"] + } +} \ No newline at end of file