Skip to content

Commit

Permalink
4.3.7.1 release (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
burtbeckwith authored Apr 15, 2024
1 parent 4803676 commit dacc32e
Show file tree
Hide file tree
Showing 101 changed files with 8,448 additions and 6,220 deletions.
11,108 changes: 5,884 additions & 5,224 deletions THIRD_PARTY_LICENSES.txt

Large diffs are not rendered by default.

42 changes: 40 additions & 2 deletions gcn/buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,56 @@ repositories {
dependencies {
implementation libs.micronaut.application
implementation libs.micronaut.library
implementation libs.nohttp
implementation libs.rocker
implementation libs.shadow
implementation libs.spotless
implementation libs.test.logger
implementation libs.tomlj
implementation libs.micronaut.internal.build.bom
compileOnly libs.rocker
}

var writeRockerHelper = tasks.register('writeRockerHelper', WriteRockerHelper) {
outputDirectory = layout.buildDirectory.dir('generated/helper')
rockerVersion = libs.versions.rocker
}

sourceSets.main.java.srcDir(writeRockerHelper)

gradlePlugin {
plugins {
rockerPlugin {
id = 'gcn.rocker'
implementationClass = 'cloud.graal.gcn.rocker.plugin.RockerPlugin'
}
gcnBomPlugin {
id = 'gcn.bom'
implementationClass = 'cloud.graal.gcn.pom.GcnBomPlugin'
}
versionCatalogUpdates {
id = 'gcn.version-catalog-updates'
implementationClass = 'cloud.graal.gcn.dependencies.GcnVersionCatalogUpdatePlugin'
}
}
}

abstract class WriteRockerHelper extends DefaultTask {
@OutputDirectory
abstract DirectoryProperty getOutputDirectory()

@Input
abstract Property<String> getRockerVersion()

@TaskAction
void execute() {
var outputFile = outputDirectory.get().asFile.toPath()
.resolve('cloud/graal/gcn/rocker/plugin/RockerHelper.java')
outputFile.parent.toFile().mkdirs()
outputFile.text = """\
package cloud.graal.gcn.rocker.plugin;
abstract class RockerHelper {
public static final String VERSION = "${rockerVersion.get()}";
}
"""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* Copyright 2024 Oracle and/or its affiliates
*
* 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.
*/

package cloud.graal.gcn.dependencies

import org.gradle.api.DefaultTask
import org.gradle.api.artifacts.VersionCatalog
import org.gradle.api.file.DirectoryProperty
import org.gradle.api.internal.file.FileOperations
import org.gradle.api.provider.Property
import org.gradle.api.tasks.CacheableTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.Internal
import org.gradle.api.tasks.OutputDirectory
import org.gradle.api.tasks.TaskAction

import javax.inject.Inject
import java.nio.file.Files
import java.nio.file.Path

@CacheableTask
abstract class DependenciesSourceGenerator extends DefaultTask {

@Internal
abstract Property<VersionCatalog> getVersionCatalog()

@Input
def getDependencies() {
versionCatalog.map { versionCatalog ->
versionCatalog.libraryAliases
.collect { alias ->
def library = versionCatalog.findLibrary(alias).get()
if (library.isPresent()) {
def lib = library.get()
def artifactId = lib.module.name
def groupId = lib.module.group
def version = lib.versionConstraint.requiredVersion
def pom = alias.startsWith("bom-") ? "true" : "false"
"${artifactId}:${groupId}:${version}:${pom}"
} else {
null
}
}
.findAll { it != null }
.toSet()
}
}

@Input
abstract Property<String> getPackageName()

@OutputDirectory
abstract DirectoryProperty getOutputDirectory()

@Inject
abstract FileOperations getFileOperations()

@TaskAction
void generateSources() {
def outputDirectory = outputDirectory.get().asFile
String packageName = packageName.get()
Path packageDirectory = outputDirectory.toPath().resolve(packageName.replace('.', '/'))
fileOperations.delete(outputDirectory)
Files.createDirectories(packageDirectory)
new File(packageDirectory.toFile(), "GcnDependencies.java").withPrintWriter { writer ->
writer.println("package $packageName;")
writer.println()
writer.println("import java.util.Collections;")
writer.println("import java.util.HashMap;")
writer.println("import java.util.Map;")
writer.println("import io.micronaut.starter.build.dependencies.Dependency;")
writer.println()
writer.println("public class GcnDependencies {")
writer.println(" public static final Map<String, Dependency> ALL_DEPENDENCIES;")
def dependenciesMap = [:]
def versionCatalog = getVersionCatalog().get()
writeDependencies(writer, dependenciesMap, versionCatalog, true)
writeDependencies(writer, dependenciesMap, versionCatalog, false)
writer.println()
writer.println(" static {")
writer.println(" Map<String, Dependency> dependencies = new HashMap<>();")
dependenciesMap.each { key, value ->
writer.println(" dependencies.put(\"$key\", $value);")
}
writer.println(" ALL_DEPENDENCIES = Collections.unmodifiableMap(dependencies);")
writer.println(" }")
writer.println("}")
}
}

static void writeDependencies(writer, Map dependenciesMap, versionCatalog, boolean bom) {
versionCatalog.libraryAliases
.findAll { alias -> bom == alias.startsWith("bom.") }
.collect { versionCatalog.findLibrary(it).orElse(null) }
.findAll { it != null }
.sort { a, b -> a.get().module.name <=> b.get().module.name }
.each { lib ->
String artifactId = lib.get().module.name
String groupId = lib.get().module.group
String version = lib.get().versionConstraint.requiredVersion
String pom = bom ? "true" : "false"
String name = artifactId.toUpperCase().replaceAll('-', '_').replaceAll('\\.', '_')
writer.println(" public static final Dependency $name = Dependency.builder()\n" +
" .groupId(\"$groupId\")\n" +
" .artifactId(\"$artifactId\")\n" +
" .version(\"$version\")\n" +
" .pom($pom)\n" +
" .build();")
dependenciesMap.put(artifactId, name)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package cloud.graal.gcn.dependencies

import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.file.Directory
import org.gradle.api.tasks.Copy
import org.gradle.api.tasks.TaskContainer
import org.gradle.api.tasks.TaskProvider

class GcnVersionCatalogUpdatePlugin implements Plugin<Project> {

void apply(Project project) {
TaskContainer tasks = project.tasks
Directory gradleDirectory = project.layout.projectDirectory.dir("../gradle")
TaskProvider<VersionCatalogUpdate> updater = tasks.register("updateVersionCatalogs", VersionCatalogUpdate.class, task -> {
task.catalogsDirectory.convention(gradleDirectory)
task.outputDirectory.convention(project.getLayout().getBuildDirectory().dir("catalogs-update"))
task.rejectedQualifiers.convention(["alpha", "beta", "rc", "cr", "m", "preview", "b", "ea"])
task.ignoredModules.convention([
"org.jetbrains.kotlin:kotlin-annotation-processing-embeddable",
"org.jetbrains.kotlin:kotlin-compiler-embeddable",
"org.jetbrains.kotlin:kotlin-reflect",
"org.jetbrains.kotlin:kotlin-stdlib",
"org.jetbrains.kotlin:kotlin-stdlib-jdk8",
"org.jetbrains.kotlin:kotlin-test"
])
task.allowMajorUpdates.convention(false)
task.allowMinorUpdates.convention(false)
})
tasks.register("useLatestVersions", Copy, task -> {
VersionCatalogUpdate dependent = updater.get()
task.from(dependent.outputDirectory)
task.into(project.providers.environmentVariable("CI").map(value -> gradleDirectory).orElse(dependent.catalogsDirectory))
})
tasks.register("dependencyUpdates", task -> task.setDescription("Compatibility task with the old update mechanism"))
}
}
Loading

0 comments on commit dacc32e

Please sign in to comment.