Skip to content

Commit

Permalink
build: publish version catalog and BOM
Browse files Browse the repository at this point in the history
  • Loading branch information
kris7t committed Jul 8, 2024
1 parent f930f23 commit bbc730b
Show file tree
Hide file tree
Showing 13 changed files with 282 additions and 100 deletions.
4 changes: 2 additions & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2021-2023 The Refinery Authors
# SPDX-FileCopyrightText: 2021-2024 The Refinery Authors
#
# SPDX-License-Identifier: EPL-2.0

Expand All @@ -24,7 +24,7 @@ ij_any_indent_case_from_switch = false
indent_style = space
indent_size = 2

[libs.versions.toml]
[*.versions.toml]
max_line_length = 999

[*.{ecore,genmodel}]
Expand Down
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.siouan.frontendgradleplugin.infrastructure.gradle.RunYarn

plugins {
alias(libs.plugins.versions)
alias(pluginLibs.plugins.versions)
id("tools.refinery.gradle.eclipse")
id("tools.refinery.gradle.frontend-worktree")
id("tools.refinery.gradle.sonarqube")
Expand Down Expand Up @@ -76,7 +76,7 @@ val mavenRepositoryTar by tasks.registering(Tar::class) {
gradle.projectsEvaluated {
mavenRepositoryTar.configure {
for (subproject in rootProject.subprojects) {
if (subproject.plugins.hasPlugin(JavaPlugin::class)) {
if (subproject.plugins.hasPlugin(MavenPublishPlugin::class)) {
dependsOn(subproject.tasks.named("publishMavenJavaPublicationToFileRepository"))
}
}
Expand Down
10 changes: 5 additions & 5 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
* SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
* SPDX-FileCopyrightText: 2021-2024 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/

plugins {
`kotlin-dsl`
alias(libs.plugins.versions)
alias(pluginLibs.plugins.versions)
}

repositories {
Expand All @@ -15,9 +15,9 @@ repositories {
}

dependencies {
implementation(libs.gradlePlugin.frontend)
implementation(libs.gradlePlugin.shadow)
implementation(libs.gradlePlugin.sonarqube)
implementation(pluginLibs.frontend)
implementation(pluginLibs.shadow)
implementation(pluginLibs.sonarqube)
// https://github.com/gradle/gradle/issues/15383
implementation(files(libs.javaClass.superclass.protectionDomain.codeSource.location))
}
8 changes: 7 additions & 1 deletion buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
/*
* SPDX-FileCopyrightText: 2021-2023 The Refinery Authors <https://refinery.tools/>
* SPDX-FileCopyrightText: 2021-2024 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/

rootProject.name = "buildSrc"

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}

create("pluginLibs") {
from(files("../gradle/pluginLibs.versions.toml"))
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,15 @@
package tools.refinery.gradle.internal

import org.gradle.accessors.dm.LibrariesForLibs
import org.gradle.configurationcache.extensions.capitalized
import tools.refinery.gradle.utils.EclipseUtils

plugins {
jacoco
java
`maven-publish`
signing
id("tools.refinery.gradle.eclipse")
id("tools.refinery.gradle.maven-publish")
}

val mavenRepositoryDir = rootProject.layout.buildDirectory.map { it.dir("repo") }

repositories {
mavenCentral()
}
Expand All @@ -31,10 +27,12 @@ configurations.testRuntimeClasspath {
val libs = the<LibrariesForLibs>()

dependencies {
implementation(platform(project(":refinery-bom-dependencies")))
compileOnly(libs.jetbrainsAnnotations)
testCompileOnly(libs.jetbrainsAnnotations)
testImplementation(libs.hamcrest)
testImplementation(libs.junit.api)
testImplementation(platform(libs.junit.bom))
testRuntimeOnly(libs.junit.engine)
testRuntimeOnly(libs.junit.launcher)
testImplementation(libs.junit.params)
Expand All @@ -53,54 +51,8 @@ java {
}
}

open class MavenArtifactExtension(project: Project) {
var name: String = project.name.split("-").drop(1).joinToString(" ", transform = String::capitalized)
var description: String? = null
}

val artifactExtension = project.extensions.create<MavenArtifactExtension>("mavenArtifact", project)

publishing {
publications {
create<MavenPublication>("mavenJava") {
from(components["java"])
pom {
name = provider { "Refinery ${artifactExtension.name}" }
description = provider {
val prefix = artifactExtension.description ?: artifactExtension.name.lowercase().capitalized()
"$prefix in Refinery, an efficient graph solver for generating well-formed models"
}
url = "https://refinery.tools/"
licenses {
license {
name = "Eclipse Public License - v 2.0"
url = "https://www.eclipse.org/legal/epl-2.0/"
}
}
developers {
developer {
name = "The Refinery Authors"
url = "https://refinery.tools/"
}
}
scm {
connection = "scm:git:https://github.com/graphs4value/refinery.git"
developerConnection = "scm:git:ssh://github.com:graphs4value/refinery.git"
url = "https://github.com/graphs4value/refinery"
}
issueManagement {
url = "https://github.com/graphs4value/refinery/issues"
}
}
}
}

repositories {
maven {
name = "file"
setUrl(mavenRepositoryDir.map { uri(it) })
}
}
publishing.publications.named<MavenPublication>("mavenJava") {
from(components["java"])
}

tasks {
Expand Down Expand Up @@ -148,11 +100,6 @@ tasks {
eclipseClasspath {
dependsOn(generateEclipseSourceFolders)
}

named<PublishToMavenRepository>("publishMavenJavaPublicationToFileRepository") {
mustRunAfter(rootProject.tasks.named("cleanMavenRepository"))
outputs.dir(mavenRepositoryDir)
}
}

fun collectDependentProjects(configuration: Configuration, dependentProjects: MutableCollection<Project>) {
Expand Down Expand Up @@ -192,17 +139,6 @@ gradle.projectsEvaluated {
}
}

signing {
// The underlying property cannot be set publicly.
@Suppress("UsePropertyAccessSyntax")
setRequired(project.hasProperty("forceSign"))
val signingKeyId = System.getenv("PGP_KEY_ID")
val signingKey = System.getenv("PGP_KEY")
val signingPassword = System.getenv("PGP_PASSWORD")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign(publishing.publications["mavenJava"])
}

eclipse {
EclipseUtils.patchClasspathEntries(this) { entry ->
if (entry.path.endsWith("-gen")) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* SPDX-FileCopyrightText: 2024 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
package tools.refinery.gradle

plugins {
`java-platform`
id("tools.refinery.gradle.maven-publish")
}

javaPlatform {
allowDependencies()
}

publishing.publications.named<MavenPublication>("mavenJava") {
from(components["javaPlatform"])
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
* SPDX-FileCopyrightText: 2024 The Refinery Authors <https://refinery.tools/>
*
* SPDX-License-Identifier: EPL-2.0
*/
package tools.refinery.gradle

import org.gradle.configurationcache.extensions.capitalized

plugins {
`maven-publish`
signing
}

val mavenRepositoryDir = rootProject.layout.buildDirectory.map { it.dir("repo") }

open class MavenArtifactExtension(project: Project) {
var name: String = project.name.split("-").drop(1).joinToString(" ", transform = String::capitalized)
var description: String? = null
}

val artifactExtension = project.extensions.create<MavenArtifactExtension>("mavenArtifact", project)

publishing {
publications {
create<MavenPublication>("mavenJava") {
pom {
name = provider { "Refinery ${artifactExtension.name}" }
description = provider {
val prefix = artifactExtension.description ?: artifactExtension.name.lowercase().capitalized()
"$prefix in Refinery, an efficient graph solver for generating well-formed models"
}
url = "https://refinery.tools/"
licenses {
license {
name = "Eclipse Public License - v 2.0"
url = "https://www.eclipse.org/legal/epl-2.0/"
}
}
developers {
developer {
name = "The Refinery Authors"
url = "https://refinery.tools/"
}
}
scm {
connection = "scm:git:https://github.com/graphs4value/refinery.git"
developerConnection = "scm:git:ssh://github.com:graphs4value/refinery.git"
url = "https://github.com/graphs4value/refinery"
}
issueManagement {
url = "https://github.com/graphs4value/refinery/issues"
}
}
}
}

repositories {
maven {
name = "file"
setUrl(mavenRepositoryDir.map { uri(it) })
}
}
}

tasks.named<PublishToMavenRepository>("publishMavenJavaPublicationToFileRepository") {
mustRunAfter(rootProject.tasks.named("cleanMavenRepository"))
outputs.dir(mavenRepositoryDir)
}

signing {
// The underlying property cannot be set publicly.
@Suppress("UsePropertyAccessSyntax")
setRequired(project.hasProperty("forceSign"))
val signingKeyId = System.getenv("PGP_KEY_ID")
val signingKey = System.getenv("PGP_KEY")
val signingPassword = System.getenv("PGP_PASSWORD")
useInMemoryPgpKeys(signingKeyId, signingKey, signingPassword)
sign(publishing.publications["mavenJava"])
}
48 changes: 27 additions & 21 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,62 @@

[versions]
eclipseCollections = "11.1.0"
ecore = "2.36.0"
ecoreCodegen = "2.38.0"
ecoreXmi = "2.37.0"
gson = "2.11.0"
hamcrest = "2.2"
jcommander = "1.83"
jetbrainsAnnotations = "24.1.0"
jetty = "12.0.11"
jmh = "1.37"
junit = "5.10.3"
mockito = "5.12.0"
mwe = "1.12.0"
mwe2 = "2.18.0"
ortools = "9.10.4067"
refineryZ3 = "4.12.6"
slf4j = "2.0.13"
xtext = "2.35.0"
xtextAntlrGenerator = "2.1.1"

[libraries]
eclipseCollections = { group = "org.eclipse.collections", name = "eclipse-collections", version.ref = "eclipseCollections" }
eclipseCollections-api = { group = "org.eclipse.collections", name = "eclipse-collections-api", version.ref = "eclipseCollections" }
ecore = { group = "org.eclipse.emf", name = "org.eclipse.emf.ecore", version = "2.36.0" }
ecore-xmi = { group = "org.eclipse.emf", name = "org.eclipse.emf.ecore.xmi", version = "2.37.0" }
ecore-codegen = { group = "org.eclipse.emf", name = "org.eclipse.emf.codegen.ecore", version = "2.38.0" }
gradlePlugin-frontend = { group = "org.siouan", name = "frontend-jdk21", version = "8.1.0" }
gradlePlugin-shadow = { group = "io.github.goooler.shadow", name = "shadow-gradle-plugin", version = "8.1.8" }
gradlePlugin-sonarqube = { group = "org.sonarsource.scanner.gradle", name = "sonarqube-gradle-plugin", version = "5.1.0.4882" }
gson = { group = "com.google.code.gson", name = "gson", version = "2.11.0" }
hamcrest = { group = "org.hamcrest", name = "hamcrest", version = "2.2" }
jcommander = { group = "org.jcommander", name = "jcommander", version = "1.83" }
jetbrainsAnnotations = { group = "org.jetbrains", name = "annotations", version = "24.1.0" }
ecore = { group = "org.eclipse.emf", name = "org.eclipse.emf.ecore", version.ref = "ecore" }
ecore-codegen = { group = "org.eclipse.emf", name = "org.eclipse.emf.codegen.ecore", version.ref = "ecoreCodegen" }
ecore-xmi = { group = "org.eclipse.emf", name = "org.eclipse.emf.ecore.xmi", version.ref = "ecoreXmi" }
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
hamcrest = { group = "org.hamcrest", name = "hamcrest", version.ref = "hamcrest" }
jcommander = { group = "org.jcommander", name = "jcommander", version.ref = "jcommander" }
jetbrainsAnnotations = { group = "org.jetbrains", name = "annotations", version.ref = "jetbrainsAnnotations" }
jetty-server = { group = "org.eclipse.jetty", name = "jetty-server", version.ref = "jetty" }
jetty-servlet = { group = "org.eclipse.jetty.ee10", name = "jetty-ee10-servlet", version.ref = "jetty" }
jetty-websocket-api = { group = "org.eclipse.jetty.websocket", name = "jetty-websocket-jetty-api", version.ref = "jetty" }
jetty-websocket-client = { group = "org.eclipse.jetty.websocket", name = "jetty-websocket-jetty-client", version.ref = "jetty" }
jetty-websocket-server = { group = "org.eclipse.jetty.ee10.websocket", name = "jetty-ee10-websocket-jetty-server", version.ref = "jetty" }
jmh-core = { group = "org.openjdk.jmh", name = "jmh-core", version.ref = "jmh" }
jmh-annprocess = { group = "org.openjdk.jmh", name = "jmh-generator-annprocess", version.ref = "jmh" }
junit-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit" }
junit-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit" }
junit-launcher = { group = "org.junit.platform", name = "junit-platform-launcher", version = "1.10.3" }
junit-params = { group = "org.junit.jupiter", name = "junit-jupiter-params", version.ref = "junit" }
junit-api = { group = "org.junit.jupiter", name = "junit-jupiter-api" }
junit-bom = { group = "org.junit", name = "junit-bom", version.ref = "junit" }
junit-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine" }
junit-launcher = { group = "org.junit.platform", name = "junit-platform-launcher" }
junit-params = { group = "org.junit.jupiter", name = "junit-jupiter-params" }
mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" }
mockito-junit = { group = "org.mockito", name = "mockito-junit-jupiter", version.ref = "mockito" }
mwe-utils = { group = "org.eclipse.emf", name = "org.eclipse.emf.mwe.utils", version = "1.12.0" }
mwe-utils = { group = "org.eclipse.emf", name = "org.eclipse.emf.mwe.utils", version.ref = "mwe" }
mwe2-launch = { group = "org.eclipse.emf", name = "org.eclipse.emf.mwe2.launch", version.ref = "mwe2" }
mwe2-lib = { group = "org.eclipse.emf", name = "org.eclipse.emf.mwe2.lib", version.ref = "mwe2" }
ortools = { group = "com.google.ortools", name = "ortools-java", version = "9.10.4067" }
refinery-z3 = { group = "tools.refinery.z3", name = "refinery-z3-solver", version = "4.12.6" }
ortools = { group = "com.google.ortools", name = "ortools-java", version.ref = "ortools" }
refinery-z3 = { group = "tools.refinery.z3", name = "refinery-z3-solver", version.ref = "refineryZ3" }
slf4j-api = { group = "org.slf4j", name = "slf4j-api", version.ref = "slf4j" }
slf4j-simple = { group = "org.slf4j", name = "slf4j-simple", version.ref = "slf4j" }
slf4j-log4j = { group = "org.slf4j", name = "log4j-over-slf4j", version.ref = "slf4j" }
xtext-core = { group = "org.eclipse.xtext", name = "org.eclipse.xtext", version.ref = "xtext" }
xtext-generator-antlr = { group = "org.eclipse.xtext", name = "xtext-antlr-generator", version = "2.1.1" }
xtext-generator-antlr = { group = "org.eclipse.xtext", name = "xtext-antlr-generator", version.ref = "xtextAntlrGenerator" }
xtext-generator = { group = "org.eclipse.xtext", name = "org.eclipse.xtext.xtext.generator", version.ref = "xtext" }
xtext-ide = { group = "org.eclipse.xtext", name = "org.eclipse.xtext.ide", version.ref = "xtext" }
xtext-testing = { group = "org.eclipse.xtext", name = "org.eclipse.xtext.testing", version.ref = "xtext" }
xtext-web = { group = "org.eclipse.xtext", name = "org.eclipse.xtext.web", version.ref = "xtext" }
xtext-xbase = { group = "org.eclipse.xtext", name = "org.eclipse.xtext.xbase", version.ref = "xtext" }
xtext-xbase-ide = { group = "org.eclipse.xtext", name = "org.eclipse.xtext.xbase.ide", version.ref = "xtext" }

[plugins]
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
Loading

0 comments on commit bbc730b

Please sign in to comment.