Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-1443.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Properly declare all required dependencies for generated code
links:
- https://github.com/palantir/metric-schema/pull/1443
7 changes: 7 additions & 0 deletions gradle-metric-schema/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ dependencies {
testImplementation 'com.netflix.nebula:nebula-test'
testImplementation 'commons-io:commons-io'

// These need to contain the dependencies added by the plugin
testRuntimeOnly 'com.google.errorprone:error_prone_annotations'
testRuntimeOnly 'com.palantir.tritium:tritium-registry'
testRuntimeOnly 'com.palantir.safe-logging:preconditions'
testRuntimeOnly 'com.palantir.safe-logging:safe-logging'
testRuntimeOnly 'io.dropwizard.metrics:metrics-core'

compileOnly 'org.immutables:value::annotations'
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ private static void configureProjectDependencies(Project project) {
project.getDependencies().add("api", "com.palantir.tritium:tritium-registry");
project.getDependencies().add("api", "com.palantir.safe-logging:preconditions");
project.getDependencies().add("api", "com.google.errorprone:error_prone_annotations");
project.getDependencies().add("implementation", "com.palantir.safe-logging:safe-logging");
project.getDependencies().add("implementation", "io.dropwizard.metrics:metrics-core");
}

private String defaultLibraryName(Project project) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package com.palantir.metric.schema.gradle

import com.google.common.base.Throwables
import com.palantir.gradle.plugintesting.TestContentHelpers

import java.nio.file.Files
import java.nio.file.StandardCopyOption
import nebula.test.IntegrationSpec
Expand Down Expand Up @@ -57,22 +59,36 @@ class MetricSchemaPluginIntegrationSpec extends IntegrationSpec {

void setup() {
buildFile << """
buildscript {
repositories {
mavenCentral()
gradlePluginPortal()
}

dependencies {
classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.32.0'
classpath 'com.palantir.baseline:gradle-baseline-java:6.25.0'
}
}

apply plugin: 'com.palantir.consistent-versions'
allprojects {
${applyPlugin(MetricSchemaPlugin.class)}
group 'com.palantir.test'

repositories {
mavenCentral()
}

configurations.all {
resolutionStrategy {
force 'com.palantir.tritium:tritium-registry:${Versions.TRITIUM}'
force 'com.palantir.safe-logging:preconditions:${Versions.SAFE_LOGGING}'
}
}
}
""".stripIndent()
TestContentHelpers.addVersionsToPropsFile(file('versions.props'), [
'com.google.errorprone:error_prone_annotations',
'com.palantir.tritium:tritium-registry',
'com.palantir.safe-logging:preconditions',
'com.palantir.safe-logging:safe-logging',
'io.dropwizard.metrics:metrics-core'
])
Comment on lines +84 to +90
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also moved to using TestContentHelpers rather than forcing explicit versions

runTasksSuccessfully('--write-locks')
}

def 'handles shorthand schema'() {
Expand Down Expand Up @@ -321,4 +337,24 @@ class MetricSchemaPluginIntegrationSpec extends IntegrationSpec {
then:
fileExists('foo-server/build/metricSchema/manifest.json')
}

def 'declare exact dependencies'() {
setup:
buildFile << """
apply plugin: 'com.palantir.baseline'
""".stripIndent(true)
file('src/main/metrics/metrics.yml') << METRICS

when:
ExecutionResult result = runTasksSuccessfully("classes", "checkImplicitDependencies", "checkUnusedDependencies")

then:
result.wasExecuted(':generateMetrics')
fileExists("build/generated/sources/metricSchema/java/main/com/palantir/test/ServerMetrics.java")

result.wasExecuted(":checkImplicitDependenciesMain")
!result.wasSkipped(":checkImplicitDependenciesMain")
result.wasExecuted(":checkUnusedDependenciesMain")
!result.wasSkipped(":checkUnusedDependenciesMain")
}
}
2 changes: 1 addition & 1 deletion versions.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ com.palantir.safe-logging:preconditions:3.9.0 (9 constraints: d78d622c)
com.palantir.safe-logging:safe-logging:3.9.0 (9 constraints: 259bec48)
com.palantir.sls.versions:sls-versions:1.5.0 (1 constraints: 0805ff35)
com.palantir.tokens:auth-tokens:3.18.0 (1 constraints: 2410a8a9)
com.palantir.tritium:tritium-ids:0.101.0 (1 constraints: f50f7da6)
com.palantir.tritium:tritium-ids:0.102.0 (1 constraints: f50f7da6)
com.palantir.tritium:tritium-registry:0.102.0 (2 constraints: 0c22b8ab)
com.squareup:javapoet:1.13.0 (2 constraints: 2b113eee)
io.dropwizard.metrics:metrics-core:4.2.33 (2 constraints: 472d0397)
Expand Down
2 changes: 1 addition & 1 deletion versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ org.assertj:assertj-core = 3.27.3
org.immutables:* = 2.11.1
org.mockito:mockito-core = 5.18.0
org.slf4j:* = 2.0.17
com.palantir.tritium:tritium-registry = 0.102.0
com.palantir.tritium:* = 0.102.0
com.palantir.conjure.java:* = 8.50.0
com.palantir.conjure.java.runtime:* = 8.22.0
com.palantir.conjure:conjure = 4.51.0
Expand Down