-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Migrate some build logic to conventions of other repos. * spotlessApply * Fix groovy compile version * Regex
- Loading branch information
Anuraag Agrawal
authored
Jun 30, 2021
1 parent
26476ae
commit 4bfd97d
Showing
45 changed files
with
285 additions
and
533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
// When updating, update below in dependencies too | ||
id("com.diffplug.spotless") version "5.14.0" | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
mavenLocal() | ||
} | ||
|
||
dependencies { | ||
// When updating, update above in plugins too | ||
implementation("com.diffplug.spotless:spotless-plugin-gradle:5.14.0") | ||
} |
37 changes: 37 additions & 0 deletions
37
buildSrc/src/main/kotlin/otel.groovy-conventions.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
plugins { | ||
groovy | ||
|
||
id("otel.java-conventions") | ||
id("otel.spotless-conventions") | ||
} | ||
|
||
dependencies { | ||
testImplementation("org.spockframework:spock-core:1.3-groovy-2.5") { | ||
exclude("org.codehaus.groovy", "groovy-all") | ||
} | ||
} | ||
|
||
spotless { | ||
groovy { | ||
greclipse() | ||
indentWithSpaces() | ||
trimTrailingWhitespace() | ||
endWithNewline() | ||
excludeJava() | ||
licenseHeaderFile(rootProject.file("config/license/spotless.license.java"), "(package|import|class|def|// Includes work from:)") | ||
} | ||
|
||
groovyGradle { | ||
greclipse() | ||
indentWithSpaces() | ||
trimTrailingWhitespace() | ||
endWithNewline() | ||
} | ||
} | ||
|
||
tasks { | ||
withType<GroovyCompile> { | ||
sourceCompatibility = "8" | ||
targetCompatibility = "8" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
plugins { | ||
`java-library` | ||
|
||
id("otel.spotless-conventions") | ||
} | ||
|
||
group = "io.opentelemetry.contrib" | ||
version = "1.0.0-alpha" | ||
|
||
base.archivesBaseName = "${rootProject.name}-${project.name}" | ||
|
||
java { | ||
toolchain { | ||
languageVersion.set(JavaLanguageVersion.of(11)) | ||
} | ||
|
||
withJavadocJar() | ||
withSourcesJar() | ||
} | ||
|
||
tasks { | ||
withType<JavaCompile>().configureEach { | ||
with(options) { | ||
release.set(8) | ||
} | ||
} | ||
|
||
val integrationTest by registering { | ||
dependsOn(test) | ||
} | ||
|
||
test { | ||
if (gradle.startParameter.taskNames.contains(integrationTest.name)) { | ||
systemProperty("ojc.integration.tests", "true") | ||
} | ||
} | ||
} | ||
|
||
val dependencyManagement by configurations.creating { | ||
isCanBeConsumed = false | ||
isCanBeResolved = false | ||
isVisible = false | ||
} | ||
|
||
dependencies { | ||
dependencyManagement(platform(project(":dependencyManagement"))) | ||
afterEvaluate { | ||
configurations.configureEach { | ||
if (isCanBeResolved && !isCanBeConsumed) { | ||
extendsFrom(dependencyManagement) | ||
} | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
buildSrc/src/main/kotlin/otel.spotless-conventions.gradle.kts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
plugins { | ||
id("com.diffplug.spotless") | ||
} | ||
|
||
spotless { | ||
java { | ||
googleJavaFormat() | ||
licenseHeaderFile(rootProject.file("config/license/spotless.license.java"), "(package|import|public|class|// Includes work from:)") | ||
} | ||
|
||
format("misc") { | ||
// not using "**/..." to help keep spotless fast | ||
target(".gitignore", "*.md", "src/**/*.md", "*.sh", "src/**/*.properties") | ||
indentWithSpaces() | ||
trimTrailingWhitespace() | ||
endWithNewline() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask | ||
|
||
plugins { | ||
`java-platform` | ||
|
||
id("com.github.ben-manes.versions") | ||
} | ||
|
||
data class DependencySet(val group: String, val version: String, val modules: List<String>) | ||
|
||
val dependencyVersions = hashMapOf<String, String>() | ||
rootProject.extra["versions"] = dependencyVersions | ||
|
||
val DEPENDENCY_BOMS = listOf( | ||
"io.opentelemetry:opentelemetry-bom:1.0.0", | ||
"io.opentelemetry:opentelemetry-bom-alpha:1.0.0-alpha" | ||
) | ||
|
||
val DEPENDENCY_SETS = listOf<DependencySet>() | ||
|
||
val DEPENDENCIES = listOf( | ||
"org.spockframework:spock-core:1.3-groovy-2.5" | ||
) | ||
|
||
javaPlatform { | ||
allowDependencies() | ||
} | ||
|
||
dependencies { | ||
for (bom in DEPENDENCY_BOMS) { | ||
api(enforcedPlatform(bom)) | ||
val split = bom.split(':') | ||
dependencyVersions[split[0]] = split[2] | ||
} | ||
constraints { | ||
for (set in DEPENDENCY_SETS) { | ||
for (module in set.modules) { | ||
api("${set.group}:${module}:${set.version}") | ||
dependencyVersions[set.group] = set.version | ||
} | ||
} | ||
for (dependency in DEPENDENCIES) { | ||
api(dependency) | ||
val split = dependency.split(':') | ||
dependencyVersions[split[0]] = split[2] | ||
} | ||
} | ||
} | ||
|
||
fun isNonStable(version: String): Boolean { | ||
val stableKeyword = listOf("RELEASE", "FINAL", "GA").any { version.toUpperCase().contains(it) } | ||
val regex = "^[0-9,.v-]+(-r)?$".toRegex() | ||
val isGuava = version.endsWith("-jre") | ||
val isStable = stableKeyword || regex.matches(version) || isGuava | ||
return isStable.not() | ||
} | ||
|
||
tasks { | ||
named<DependencyUpdatesTask>("dependencyUpdates") { | ||
revision = "release" | ||
checkConstraints = true | ||
|
||
rejectVersionIf { | ||
isNonStable(candidate.version) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 1 addition & 13 deletions
14
example/src/main/java/io/opentelemetry/contrib/example/Library.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.