Skip to content

Commit

Permalink
build: pin transitive dependencies
Browse files Browse the repository at this point in the history
Make sure we don't duplicate dependency versions.

org.ow2.asm:asm is still duplicated, because Xtext needs 9.7 but JaCoCo needs
9.6 instead. This only affects the jacocoAnt configuration of our Java projects.
  • Loading branch information
kris7t committed Jul 10, 2024
1 parent bf3b06f commit 3943d64
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ plugins {
id("tools.refinery.gradle.java-conventions")
}

// Use log4j-over-slf4j instead of log4j 1.x when running the application.
configurations.runtimeClasspath {
exclude(group = "log4j", module = "log4j")
}

val libs = the<LibrariesForLibs>()

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,29 @@ repositories {
mavenCentral()
}

// Use log4j-over-slf4j instead of log4j 1.x in the tests.
configurations.testRuntimeClasspath {
exclude(group = "log4j", module = "log4j")
configurations.withType(Configuration::class) {
if (name.endsWith("Classpath")) {
exclude(group = "log4j", module = "log4j")
exclude(group = "ch.qos.reload4j", module = "reload4j")
}
}

val libs = the<LibrariesForLibs>()

dependencies {
compileOnly(libs.jetbrainsAnnotations)
compileOnly(libs.slf4j.log4j)
testCompileOnly(libs.jetbrainsAnnotations)
testImplementation(libs.hamcrest)
testImplementation(libs.junit.api)
testImplementation(enforcedPlatform(libs.junit.bom))
testImplementation(enforcedPlatform(project(":refinery-bom-dependencies")))
testRuntimeOnly(libs.junit.engine)
testRuntimeOnly(libs.junit.launcher)
testRuntimeOnly(libs.slf4j.simple)
testImplementation(libs.junit.params)
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.junit)
testImplementation(libs.slf4j.simple)
testRuntimeOnly(libs.slf4j.log4j)
testImplementation(libs.slf4j.log4j)
}

java {
Expand Down
3 changes: 3 additions & 0 deletions buildSrc/src/main/kotlin/tools/refinery/gradle/jmh.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ configurations["jmhRuntimeOnly"].extendsFrom(configurations.runtimeOnly.get(), c
val libs = the<LibrariesForLibs>()

dependencies {
jmhImplementation(enforcedPlatform(project(":refinery-bom-dependencies")))
jmhImplementation(libs.jmh.core)
jmhImplementation(libs.slf4j.log4j)
jmhImplementation(libs.slf4j.simple)
jmhAnnotationProcessor(libs.jmh.annprocess)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ val mwe2: Configuration by configurations.creating {
isCanBeConsumed = false
isCanBeResolved = true
extendsFrom(configurations.implementation.get())
// Exclude also here, because the name of this configuration doesn't end with {@code Classpath},
// so it isn't caught by {@code tools.refinery.gradle.java-conventions}.
exclude(group = "log4j", module = "log4j")
exclude(group = "ch.qos.reload4j", module = "reload4j")
}

val libs = the<LibrariesForLibs>()

dependencies {
mwe2(enforcedPlatform(project(":refinery-bom-dependencies")))
mwe2(libs.mwe2.launch)
mwe2(libs.slf4j.simple)
mwe2(libs.slf4j.log4j)
mwe2(libs.slf4j.simple)
}

eclipse.classpath.plusConfigurations += mwe2
89 changes: 81 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,99 @@
# SPDX-License-Identifier: EPL-2.0

[versions]
antlr = "3.2" # To retain Xtext compatibility, this mustn't be increased
apiguardian = "1.1.2"
asm = "9.7"
classgraph = "4.8.174"
eclipse-commands = "3.12.100"
eclipse-contenttype = "3.9.400"
eclipse-debug = "3.21.400"
eclipse-filesystem = "1.10.400"
eclipse-jobs = "3.15.300"
eclipse-osgi = "3.20.0"
eclipse-resources = "3.20.200"
eclipse-runtime = "3.31.100"
eclipse-text = "3.14.100"
eclipse-variables = "3.6.400"
eclipseCollections = "11.1.0"
ecore = "2.36.0"
ecoreCodegen = "2.38.0"
ecoreXmi = "2.37.0"
ecore-change = "2.16.0"
ecore-codegen = "2.38.0"
ecore-xmi = "2.37.0"
emf-codegen = "2.23.0"
emf-common = "2.30.0"
equinox-common = "3.19.100"
equinox-preferences = "3.11.100"
equinox-registry = "3.12.100"
errorprone = "2.28.0"
findbugs = "3.0.2"
guava = "33.2.1-jre"
guice = "7.0.0"
gson = "2.11.0"
hamcrest = "2.2"
jakartaInject = "2.0.1"
jcommander = "1.83"
jdt-core = "3.38.0"
jdt-debug = "3.21.400"
jdt-launching = "3.22.0"
jetbrainsAnnotations = "24.1.0"
jetty = "12.0.11"
jmh = "1.37"
jna = "5.14.0"
junit = "5.10.3"
lsp4j = "0.23.1"
mockito = "5.12.0"
mwe = "1.12.0"
mwe2 = "2.18.0"
opentest4j = "1.3.0"
ortools = "9.10.4067"
refineryZ3 = "4.12.6"
protobuf = "4.27.2"
refinery-z3 = "4.12.6"
slf4j = "2.0.13"
xtext = "2.35.0"
xtextAntlrGenerator = "2.1.1"
xtext-generator-antlr = "2.1.1"

[libraries]
antlr = { group = "org.antlr", name = "antlr-runtime", version.ref = "antlr" }
apiguardian = { group = "org.apiguardian", name = "apiguardian-api", version.ref = "apiguardian" }
asm = { group = "org.ow2.asm", name = "asm", version.ref = "asm" }
asm-commons = { group = "org.ow2.asm", name = "asm-commons", version.ref = "asm" }
asm-tree = { group = "org.ow2.asm", name = "asm-tree", version.ref = "asm" }
classgraph = { group = "io.github.classgraph", name = "classgraph", version.ref = "classgraph" }
eclipse-commands = { group = "org.eclipse.platform", name = "org.eclipse.core.commands", version.ref = "eclipse-commands" }
eclipse-contenttype = { group = "org.eclipse.platform", name = "org.eclipse.core.contenttype", version.ref = "eclipse-contenttype" }
eclipse-debug = { group = "org.eclipse.platform", name = "org.eclipse.debug.core", version.ref = "eclipse-debug" }
eclipse-expressions = { group = "org.eclipse.platform", name = "org.eclipse.core.expressions", version.ref = "eclipse-contenttype" }
eclipse-filesystem = { group = "org.eclipse.platform", name = "org.eclipse.core.filesystem", version.ref = "eclipse-filesystem" }
eclipse-jobs = { group = "org.eclipse.platform", name = "org.eclipse.core.jobs", version.ref = "eclipse-jobs" }
eclipse-osgi = { group = "org.eclipse.platform", name = "org.eclipse.osgi", version.ref = "eclipse-osgi" }
eclipse-resources = { group = "org.eclipse.platform", name = "org.eclipse.core.resources", version.ref = "eclipse-resources" }
eclipse-runtime = { group = "org.eclipse.platform", name = "org.eclipse.core.runtime", version.ref = "eclipse-runtime" }
eclipse-text = { group = "org.eclipse.platform", name = "org.eclipse.text", version.ref = "eclipse-text" }
eclipse-variables = { group = "org.eclipse.platform", name = "org.eclipse.core.variables", version.ref = "eclipse-variables" }
eclipseCollections = { group = "org.eclipse.collections", name = "eclipse-collections-api", version.ref = "eclipseCollections" }
eclipseCollections-impl = { group = "org.eclipse.collections", name = "eclipse-collections", version.ref = "eclipseCollections" }
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" }
ecore-change = { group = "org.eclipse.emf", name = "org.eclipse.emf.ecore.change", version.ref = "ecore-change" }
ecore-codegen = { group = "org.eclipse.emf", name = "org.eclipse.emf.codegen.ecore", version.ref = "ecore-codegen" }
ecore-xmi = { group = "org.eclipse.emf", name = "org.eclipse.emf.ecore.xmi", version.ref = "ecore-xmi" }
emf-codegen = { group = "org.eclipse.emf", name = "org.eclipse.emf.codegen", version.ref = "emf-codegen" }
emf-common = { group = "org.eclipse.emf", name = "org.eclipse.emf.common", version.ref = "emf-common" }
equinox-common = { group = "org.eclipse.platform", name = "org.eclipse.equinox.common", version.ref = "equinox-common" }
equinox-preferences = { group = "org.eclipse.platform", name = "org.eclipse.equinox.preferences", version.ref = "equinox-preferences" }
equinox-registry = { group = "org.eclipse.platform", name = "org.eclipse.equinox.registry", version.ref = "equinox-registry" }
errorprone-annotations = { group = "com.google.errorprone", name = "error_prone_annotations", version.ref = "errorprone" }
findbugs-jsr305 = { group = "com.google.code.findbugs", name = "jsr305", version.ref = "findbugs" }
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
guava = { group = "com.google.guava", name = "guava", version.ref = "guava" }
guice = { group = "com.google.inject", name = "guice", version.ref = "guice" }
hamcrest = { group = "org.hamcrest", name = "hamcrest", version.ref = "hamcrest" }
jcommander = { group = "org.jcommander", name = "jcommander", version.ref = "jcommander" }
jdt-core = { group = "org.eclipse.jdt", name = "org.eclipse.jdt.core", version.ref = "jdt-core" }
jdt-debug = { group = "org.eclipse.jdt", name = "org.eclipse.jdt.debug", version.ref = "jdt-debug" }
jdt-ecj = { group = "org.eclipse.jdt", name = "ecj", version.ref = "jdt-core" }
jdt-launching = { group = "org.eclipse.jdt", name = "org.eclipse.jdt.launching", version.ref = "jdt-launching" }
jakartaInject = { group = "jakarta.inject", name = "jakarta.inject-api", version.ref = "jakartaInject" }
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" }
Expand All @@ -40,24 +104,33 @@ jetty-websocket-client = { group = "org.eclipse.jetty.websocket", name = "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" }
jna = { group = "net.java.dev.jna", name = "jna", version.ref = "jna" }
jna-platform = { group = "net.java.dev.jna", name = "jna-platform", version.ref = "jna" }
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" }
lsp4j = { group = "org.eclipse.lsp4j", name = "org.eclipse.lsp4j", version.ref = "lsp4j" }
lsp4j-jsonrpc = { group = "org.eclipse.lsp4j", name = "org.eclipse.lsp4j.jsonrpc", version.ref = "lsp4j" }
mockito-core = { group = "org.mockito", name = "mockito-core", version.ref = "mockito" }
mockito-junit = { group = "org.mockito", name = "mockito-junit-jupiter", version.ref = "mockito" }
mwe-core = { group = "org.eclipse.emf", name = "org.eclipse.emf.mwe.core", version.ref = "mwe" }
mwe-utils = { group = "org.eclipse.emf", name = "org.eclipse.emf.mwe.utils", version.ref = "mwe" }
mwe2-language = { group = "org.eclipse.emf", name = "org.eclipse.emf.mwe2.language", version.ref = "mwe2" }
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" }
mwe2-runtime = { group = "org.eclipse.emf", name = "org.eclipse.emf.mwe2.runtime", version.ref = "mwe2" }
opentest4j = { group = "org.opentestj4", name = "opentest4j", version.ref = "opentest4j" }
ortools = { group = "com.google.ortools", name = "ortools-java", version.ref = "ortools" }
refinery-z3 = { group = "tools.refinery.z3", name = "refinery-z3-solver", version.ref = "refineryZ3" }
protobuf = { group = "com.google.protobuf", name = "protobuf-java", version.ref = "protobuf" }
refinery-z3 = { group = "tools.refinery.z3", name = "refinery-z3-solver", version.ref = "refinery-z3" }
slf4j = { 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.ref = "xtextAntlrGenerator" }
xtext-generator = { group = "org.eclipse.xtext", name = "org.eclipse.xtext.xtext.generator", version.ref = "xtext" }
xtext-generator-antlr = { group = "org.eclipse.xtext", name = "xtext-antlr-generator", version.ref = "xtext-generator-antlr" }
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" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.api.component.AdhocComponentWithVariants;
import org.gradle.api.component.ConfigurationVariantDetails;
import org.gradle.api.internal.tasks.JvmConstants;
Expand All @@ -24,6 +25,7 @@

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Map;

public class RefineryJavaPlugin implements Plugin<Project> {
private static final String JUNIT_API = "org.junit.jupiter:junit-jupiter-api";
Expand Down Expand Up @@ -97,15 +99,17 @@ private static void configureDependencies(Project target, RefineryJavaExtension
dependencies.enforcedPlatform(artifact) : dependencies.platform(artifact);
}));

RefineryPluginUtils.addConditionalDependency(dependencies, JavaPlugin.COMPILE_ONLY_CONFIGURATION_NAME,
SLF4J_LOG4J, extension.getUseSlf4JLog4J());
RefineryPluginUtils.addConditionalDependency(dependencies, JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME,
SLF4J_LOG4J, extension.getUseSlf4JLog4J());
RefineryPluginUtils.addConditionalDependency(dependencies, JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME,
SLF4J_LOG4J, extension.getUseSlf4JLog4J().map(value ->
Boolean.TRUE.equals(value) && target.getPlugins().hasPlugin(ApplicationPlugin.class)));

RefineryPluginUtils.addConditionalDependency(dependencies, JavaPlugin.TEST_IMPLEMENTATION_CONFIGURATION_NAME,
RefineryPluginUtils.addConditionalDependency(dependencies, JavaPlugin.TEST_RUNTIME_ONLY_CONFIGURATION_NAME,
SLF4J_SIMPLE, extension.getUseSlf4JSimple());
RefineryPluginUtils.addConditionalDependency(dependencies, JavaPlugin.IMPLEMENTATION_CONFIGURATION_NAME,
RefineryPluginUtils.addConditionalDependency(dependencies, JavaPlugin.RUNTIME_ONLY_CONFIGURATION_NAME,
SLF4J_SIMPLE, extension.getUseSlf4JSimple().map(value ->
Boolean.TRUE.equals(value) && target.getPlugins().hasPlugin(ApplicationPlugin.class)));

Expand Down Expand Up @@ -197,10 +201,12 @@ private static void addBundleSymbolicName(Project project) {
}

private static void excludeLog4J(Project project) {
RefineryPluginUtils.excludeLog4J(project, JavaPlugin.TEST_RUNTIME_CLASSPATH_CONFIGURATION_NAME);
if (project.getPlugins().hasPlugin(ApplicationPlugin.class)) {
RefineryPluginUtils.excludeLog4J(project, JavaPlugin.RUNTIME_CLASSPATH_CONFIGURATION_NAME);
}
project.getConfigurations().withType(Configuration.class, configuration -> {
if (configuration.getName().endsWith("Classpath")) {
configuration.exclude(Map.of("group", "log4j", "module", "log4j"));
configuration.exclude(Map.of("group", "ch.qos.reload4j", "module", "reload4j"));
}
});
}

private static void configureJunitPlatform(Project project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.gradle.api.provider.Provider;

import java.util.List;
import java.util.Map;

public final class RefineryPluginUtils {
public static final String VERSION_PROPERTY = "tools.refinery.version";
Expand All @@ -26,11 +25,6 @@ private RefineryPluginUtils() {
throw new IllegalArgumentException("This is a static utility class and should not be instantiated directly.");
}

public static void excludeLog4J(Project project, String configurationName) {
var testRuntimeClasspath = project.getConfigurations().getByName(configurationName);
testRuntimeClasspath.exclude(Map.of("group", "log4j", "module", "log4j"));
}

public static void withShadowPlugin(Project project, Action<? super Project> action) {
// Method parameter in Gradle API uses raw type.
@SuppressWarnings("rawtypes")
Expand Down
2 changes: 1 addition & 1 deletion subprojects/versions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ mavenArtifact {
}

val refineryVersion = "refinery"
val interpreterVersion = "refineryInterpreter"
val interpreterVersion = "refinery-interpreter"
val interpreterGroup = property("tools.refinery.interpreter.group").toString()
val shadowVersion = "shadow"

Expand Down

0 comments on commit 3943d64

Please sign in to comment.