Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor build #220

Merged
merged 9 commits into from
Feb 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@
* SOFTWARE.
*/

pluginManagement {
includeBuild("../settings-plugins")
}

enableFeaturePreview("VERSION_CATALOGS")

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
plugins {
id("org.graalvm.build.common")
}

rootProject.name = "aggregator"
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.api.publish.plugins.PublishingPlugin
import org.gradle.api.tasks.Delete
import org.gradle.api.tasks.bundling.Zip
import org.gradle.kotlin.dsl.*

/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
*
* Subject to the condition set forth below, permission is hereby granted to any
* person obtaining a copy of this software, associated documentation and/or
* data (collectively the "Software"), free of charge and under any and all
* copyright rights in the Software, and any and all patent rights owned or
* freely licensable by each licensor hereunder covering either (i) the
* unmodified Software as contributed to or provided by such licensor, or (ii)
* the Larger Works (as defined below), to deal in both
*
* (a) the Software, and
*
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
* one is included with the Software each a "Larger Work" to which the Software
* is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create
* derivative works of, display, perform, and distribute the Software and make,
* use, sell, offer for sale, import, export, have made, and have sold the
* Software and the Larger Work(s), and to sublicense the foregoing rights on
* either these or other terms.
*
* This license is subject to the following condition:
*
* The above copyright notice and either this complete permission notice or at a
* minimum a reference to the UPL must 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.
*/

plugins {
base
}

tasks.named("clean") {
gradle.includedBuilds.forEach {
dependsOn(it.task(":clean"))
}
}

tasks.register("test") {
gradle.includedBuilds.forEach {
dependsOn(it.task(":test"))
}
}

tasks.register("inspections") {
gradle.includedBuilds.forEach {
dependsOn(it.task(":inspections"))
}
}

tasks.named("check") {
gradle.includedBuilds.forEach {
dependsOn(it.task(":check"))
}
}

listOf(
"publishTo" to "MavenLocal",
"publishAllPublicationsTo" to "CommonRepository",
"publishAllPublicationsTo" to "SnapshotsRepository",
).forEach { entry ->
val (taskPrefix, repo) = entry
tasks.register("$taskPrefix$repo") {
description = "Publishes all artifacts to the ${repo.decapitalize()} repository"
group = PublishingPlugin.PUBLISH_TASK_GROUP
gradle.includedBuilds.forEach {
if (it.name != "docs" && !it.projectDir.path.contains("build-logic")) {
dependsOn(it.task(":$taskPrefix$repo"))
}
}
doFirst {
if (gradle.startParameter.isParallelProjectExecutionEnabled) {
throw RuntimeException("Publishing should be done using --no-parallel")
}
}
}
}

val commonRepo = layout.buildDirectory.dir("common-repo")
val snapshotsRepo = layout.buildDirectory.dir("snapshots")

val pruneCommonRepo = tasks.register<Delete>("pruneCommonRepository") {
delete(commonRepo)
}

val catalogs = extensions.getByType<VersionCatalogsExtension>()
val libs = catalogs.named("libs")

val nativeBuildToolsVersion = libs.findVersion("nativeBuildTools").get().requiredVersion
val junitJupiterVersion = libs.findVersion("junitJupiter").get().requiredVersion
val junitPlatformVersion = libs.findVersion("junitPlatform").get().requiredVersion

tasks.register<Zip>("releaseZip") {
archiveVersion.set(nativeBuildToolsVersion)
dependsOn(pruneCommonRepo, "publishAllPublicationsToCommonRepository")
from(commonRepo) {
exclude("**/*.sha256")
exclude("**/*.sha512")
}
}

val updateSamples by tasks.registering

mapOf(
"updateSamplesDir" to "samples",
"updateMavenReprosDir" to "native-maven-plugin/reproducers"
).forEach { taskName, dir ->
val t = tasks.register<org.graalvm.build.samples.SamplesUpdateTask>(taskName) {
inputDirectory.set(layout.projectDirectory.dir(dir))
versions.put("native.gradle.plugin.version", nativeBuildToolsVersion)
versions.put("native.maven.plugin.version", nativeBuildToolsVersion)
versions.put("junit.jupiter.version", junitJupiterVersion)
versions.put("junit.platform.version", junitPlatformVersion)
versions.put("junit.platform.native.version", nativeBuildToolsVersion)
}
updateSamples.configure {
dependsOn(t)
}
}


val cloneSnapshots = tasks.register<org.graalvm.build.tasks.GitClone>("cloneSnapshotRepository") {
repositoryUri.set("git@github.com:graalvm/native-build-tools.git")
// repositoryUri.set(file(".").absolutePath)
repositoryDirectory.set(layout.buildDirectory.dir("snapshots"))
branch.set("snapshots")
}

val prepareRepository = tasks.register<org.graalvm.build.tasks.GitReset>("resetHead") {
dependsOn(cloneSnapshots)
repositoryDirectory.set(layout.buildDirectory.dir("snapshots"))
mode.set(org.eclipse.jgit.api.ResetCommand.ResetType.HARD)
ref.set("25ecdec020f57dbe980eeb052c71659ccd0d9bcc")
}

val addSnapshots = tasks.register<org.graalvm.build.tasks.GitAdd>("addSnapshots") {
dependsOn(prepareRepository)
repositoryDirectory.set(layout.buildDirectory.dir("snapshots"))
pattern.set("org/")
}

val commitSnapshots = tasks.register<org.graalvm.build.tasks.GitCommit>("commitSnapshots") {
dependsOn(addSnapshots)
repositoryDirectory.set(layout.buildDirectory.dir("snapshots"))
message.set("Publishing new snapshot")
amend.set(false)
}

val pushSnapshots = tasks.register<org.graalvm.build.tasks.GitPush>("pushSnapshots") {
dependsOn(commitSnapshots)
repositoryDirectory.set(layout.buildDirectory.dir("snapshots"))
force.set(true)
}

tasks.named("publishAllPublicationsToSnapshotsRepository") {
dependsOn(prepareRepository)
finalizedBy(pushSnapshots)
onlyIf {
nativeBuildToolsVersion.endsWith("-SNAPSHOT")
}
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,4 @@
* SOFTWARE.
*/

plugins {
`java-gradle-plugin`
}
rootProject.name = "common-plugins"
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,16 @@ repositories {
mavenCentral()
}

val versionFromCatalog = extensions.getByType<VersionCatalogsExtension>()
.named("libs")
.findVersion("nativeBuildTools")

group = "org.graalvm.buildtools"
if (versionFromCatalog.isPresent()) {
version = versionFromCatalog.get().requiredVersion
} else {
throw GradleException("Version catalog doesn't define project version 'nativeBuildTools'")

extensions.findByType<VersionCatalogsExtension>()?.also { catalogs ->
val versionFromCatalog = catalogs.named("libs")
.findVersion("nativeBuildTools")
if (versionFromCatalog.isPresent()) {
version = versionFromCatalog.get().requiredVersion
} else {
throw GradleException("Version catalog doesn't define project version 'nativeBuildTools'")
}
}

tasks.javadoc {
Expand Down
42 changes: 42 additions & 0 deletions build-logic/documentation-plugins/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2020, 2021 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
*
* Subject to the condition set forth below, permission is hereby granted to any
* person obtaining a copy of this software, associated documentation and/or
* data (collectively the "Software"), free of charge and under any and all
* copyright rights in the Software, and any and all patent rights owned or
* freely licensable by each licensor hereunder covering either (i) the
* unmodified Software as contributed to or provided by such licensor, or (ii)
* the Larger Works (as defined below), to deal in both
*
* (a) the Software, and
*
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
* one is included with the Software each a "Larger Work" to which the Software
* is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create
* derivative works of, display, perform, and distribute the Software and make,
* use, sell, offer for sale, import, export, have made, and have sold the
* Software and the Larger Work(s), and to sublicense the foregoing rights on
* either these or other terms.
*
* This license is subject to the following condition:
*
* The above copyright notice and either this complete permission notice or at a
* minimum a reference to the UPL must 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.
*/

rootProject.name = "documentation-plugins"
1 change: 1 addition & 0 deletions build-logic/gradle-functional-testing/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rootProject.name = "gradle-functional-testing"
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
*/

plugins {
id 'java-gradle-plugin'
id 'groovy'
}

Expand Down
3 changes: 3 additions & 0 deletions build-logic/settings-plugins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## Settings build logic

This folder contains settings plugins used by the different Gradle builds in this repository.
49 changes: 49 additions & 0 deletions build-logic/settings-plugins/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
*
* Subject to the condition set forth below, permission is hereby granted to any
* person obtaining a copy of this software, associated documentation and/or
* data (collectively the "Software"), free of charge and under any and all
* copyright rights in the Software, and any and all patent rights owned or
* freely licensable by each licensor hereunder covering either (i) the
* unmodified Software as contributed to or provided by such licensor, or (ii)
* the Larger Works (as defined below), to deal in both
*
* (a) the Software, and
*
* (b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
* one is included with the Software each a "Larger Work" to which the Software
* is contributed by such licensors),
*
* without restriction, including without limitation the rights to copy, create
* derivative works of, display, perform, and distribute the Software and make,
* use, sell, offer for sale, import, export, have made, and have sold the
* Software and the Larger Work(s), and to sublicense the foregoing rights on
* either these or other terms.
*
* This license is subject to the following condition:
*
* The above copyright notice and either this complete permission notice or at a
* minimum a reference to the UPL must 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.
*/

plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
gradlePluginPortal()
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@
* SOFTWARE.
*/

rootProject.name = "shared-build-logic"
rootProject.name = "settings-plugins"
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@
* SOFTWARE.
*/

enableFeaturePreview("VERSION_CATALOGS")

val catalogFile = file(".").let {
var baseDir = it
var cur = File(baseDir, "gradle/libs.versions.toml")
Expand Down