Skip to content

Commit

Permalink
Merge pull request #2564 from vlsi/split_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
juherr committed Jun 3, 2021
2 parents 00eb745 + 47ffdca commit 1ce27a3
Show file tree
Hide file tree
Showing 2,265 changed files with 1,881 additions and 813 deletions.
20 changes: 20 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
root = true

[*]
trim_trailing_whitespace = true
insert_final_newline = true
charset = utf-8
indent_style = space

[{*.sh,gradlew}]
end_of_line = lf

[{*.bat,*.cmd}]
end_of_line = crlf

[*.md]
# Trailing space means "paragraph continues" in markdown
trim_trailing_whitespace = false

[*.java]
indent_size = 2
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
/local.properties
build
eclipse-build
gradle.properties
ivy*
javadocs
lib
Expand Down
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Current
Changed: GITHUB-2564: Source code is split into several modules for better modularity in the future (for now only a combined jar is released as it was before)
Added: GITHUB-2564: Added license files as META-INF/LICENSE.txt within the released jar
Test: GITHUB-2564: Added pax-exam-based OSGi test to verify the manifest
Changed: GITHUB-2564: Migrated the build to Gradle 7.0.2
Fixed: GITHUB-2576: Guice 5.0 drops no-aop variant, so TestNG should probably upgrade and avoid no-aop dependency (Nan Liang)
Fixed: GITHUB-2566: Reporter#getOutput(ITestResult tr) uses Map.get(tr.hashCode()) which might result in surprising results (Krishnan Mahadevan)
Fixed: GITHUB-2565: Dataprovider only supporting a raw type for Iterator return type (Krishnan Mahadevan)
Expand Down
3 changes: 3 additions & 0 deletions build-logic/basics/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
plugins {
`kotlin-dsl`
}
10 changes: 10 additions & 0 deletions build-logic/basics/src/main/kotlin/testng.repositories.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Can't use settings plugin: https://github.com/gradle/gradle/issues/17295
// dependencyResolutionManagement {
// repositories {
// mavenCentral()
// }
//}

repositories {
mavenCentral()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
tasks.withType<AbstractArchiveTask>().configureEach {
// Ensure builds are reproducible
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
dirMode = "775".toInt(8)
fileMode = "664".toInt(8)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
if (project != rootProject) {
// The root project takes its version from /gradle.properties -> testng.version
// All the rest projects take the version from the root
version = rootProject.version
}
11 changes: 11 additions & 0 deletions build-logic/code-quality/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
}

dependencies {
implementation("org.sonarqube:org.sonarqube.gradle.plugin:2.8")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
plugins {
id("org.sonarqube")
}

sonarqube {
properties {
property("sonar.host.url", "https://sonarcloud.io/")
property("sonar.organization", "testng-team")
property("sonar.github.repository", "cbeust/testng")
property("sonar.github.login", "testng-bot")
}
}
33 changes: 33 additions & 0 deletions build-logic/code-quality/src/main/kotlin/testng.testing.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import org.gradle.api.tasks.testing.Test
import org.gradle.kotlin.dsl.withType

plugins {
`java-library`
}

dependencies {
testImplementation("org.assertj:assertj-core:_")
}

tasks.withType<Test>().configureEach {
useTestNG()
systemProperty("test.resources.dir", "build/resources/test")
fun passProperty(name: String, default: String? = null) {
val value = System.getProperty(name) ?: default
value?.let { systemProperty(name, it) }
}
// Default verbose is 0, however, it can be adjusted vi -Dtestng.default.verbose=2
passProperty("testng.default.verbose", "0")
// Allow running tests in a custom locale with -Duser.language=...
passProperty("user.language")
passProperty("user.country")

@Suppress("unchecked_cast")
val props = System.getProperties().propertyNames() as `java.util`.Enumeration<String>
// Pass testng.* properties to the test JVM
for (e in props) {
if (e.startsWith("testng.")) {
passProperty(e)
}
}
}
14 changes: 14 additions & 0 deletions build-logic/jvm/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
}

dependencies {
implementation(project(":basics"))
implementation(project(":code-quality"))
implementation("com.github.vlsi.gradle-extensions:com.github.vlsi.gradle-extensions.gradle.plugin:1.74")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
16 changes: 16 additions & 0 deletions build-logic/jvm/src/main/kotlin/buildlogic/CopySpecExtensions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package buildlogic

import org.apache.tools.ant.filters.FixCrLfFilter
import org.gradle.api.file.CopySpec
import org.gradle.kotlin.dsl.filter

fun CopySpec.filterEolSimple(eol: String) {
filteringCharset = "UTF-8"
filter(
FixCrLfFilter::class, mapOf(
"eol" to FixCrLfFilter.CrLf.newInstance(eol),
"fixlast" to true,
"ctrlz" to FixCrLfFilter.AddAsisRemove.newInstance("asis")
)
)
}
69 changes: 69 additions & 0 deletions build-logic/jvm/src/main/kotlin/testng.java-library.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import buildlogic.filterEolSimple

plugins {
`java-library`
id("testng.java")
id("testng.testing")
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

tasks.withType<Javadoc>().configureEach {
excludes.add("org/testng/internal/**")
}

tasks.withType<JavaCompile>().configureEach {
inputs.property("java.version", System.getProperty("java.version"))
inputs.property("java.vm.version", System.getProperty("java.vm.version"))
options.apply {
encoding = "UTF-8"
compilerArgs.add("-Xlint:deprecation")
compilerArgs.add("-Werror")
}
}

tasks.withType<Jar>().configureEach {
into("META-INF") {
filterEolSimple("crlf")
from("$rootDir/LICENSE.txt")
from("$rootDir/NOTICE")
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}
manifest {
// providers.gradleProperty does not work
// see https://github.com/gradle/gradle/issues/14972
val name = rootProject.findProperty("project.name")
val vendor = rootProject.findProperty("project.vendor.name")
attributes(mapOf(
"Specification-Title" to name,
"Specification-Version" to project.version,
"Specification-Vendor" to vendor,
"Implementation-Title" to name,
"Implementation-Version" to project.version,
"Implementation-Vendor" to vendor,
"Implementation-Vendor-Id" to rootProject.findProperty("project.vendor.id"),
"Implementation-Url" to rootProject.findProperty("project.url"),
))
}
}

@Suppress("unused")
val transitiveSourcesElements by configurations.creating {
description = "Share sources folder with other projects for aggregation (e.g. sources, javadocs, etc)"
isVisible = false
isCanBeResolved = false
isCanBeConsumed = true
extendsFrom(configurations.implementation.get())
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.DOCUMENTATION))
attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named("source-folders"))
}
// afterEvaluate is to allow creation of the new source sets
afterEvaluate {
sourceSets.main.get().java.srcDirs.forEach { outgoing.artifact(it) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
plugins {
id("testng.java")
`java-platform`
}
13 changes: 13 additions & 0 deletions build-logic/jvm/src/main/kotlin/testng.java.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
plugins {
`java-base`
id("testng.versioning")
id("testng.repositories")
// Improves Gradle Test logging
// See https://github.com/vlsi/vlsi-release-plugins/tree/master/plugins/gradle-extensions-plugin
id("com.github.vlsi.gradle-extensions")
}

java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
16 changes: 16 additions & 0 deletions build-logic/jvm/src/main/kotlin/testng.kotlin-library.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
id("testng.java-library")
kotlin("jvm")
}

java {
withSourcesJar()
}

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = "1.8"
}
}
14 changes: 14 additions & 0 deletions build-logic/publishing/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
}

dependencies {
implementation(project(":jvm"))
implementation("com.github.vlsi.gradle-extensions:com.github.vlsi.gradle-extensions.gradle.plugin:1.74")
implementation("com.github.johnrengelman.shadow:com.github.johnrengelman.shadow.gradle.plugin:7.0.0")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package buildlogic

import org.gradle.api.artifacts.Configuration
import org.gradle.api.attributes.Category
import org.gradle.api.attributes.Usage
import org.gradle.api.model.ObjectFactory
import org.gradle.kotlin.dsl.named

fun Configuration.javaLibrary(objects: ObjectFactory, usage: String) =
attributes {
attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))
attribute(Usage.USAGE_ATTRIBUTE, objects.named(usage))
}

fun Configuration.javaLibraryApi(objects: ObjectFactory) =
javaLibrary(objects, Usage.JAVA_API)

fun Configuration.javaLibraryRuntime(objects: ObjectFactory) =
javaLibrary(objects, Usage.JAVA_RUNTIME)
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package buildlogic

import org.apache.tools.ant.filters.FixCrLfFilter
import org.gradle.api.file.CopySpec
import org.gradle.kotlin.dsl.filter

fun CopySpec.filterEolSimple(eol: String) {
filteringCharset = "UTF-8"
filter(
FixCrLfFilter::class, mapOf(
"eol" to FixCrLfFilter.CrLf.newInstance(eol),
"fixlast" to true,
"ctrlz" to FixCrLfFilter.AddAsisRemove.newInstance("asis")
)
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package buildlogic

import org.gradle.api.artifacts.Dependency
import org.gradle.api.artifacts.component.ModuleComponentIdentifier
import org.gradle.api.artifacts.component.ProjectComponentIdentifier
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.artifacts.result.ResolvedVariantResult
import org.gradle.api.attributes.Category
import org.gradle.kotlin.dsl.create
import org.gradle.kotlin.dsl.project

/**
* Converts the resolved result back to a dependency notation, so it can be resolved again.
* Note: the conversion does not support "classifiers"
*/
fun DependencyHandler.reconstruct(variant: ResolvedVariantResult): Dependency {
val category = variant.attributes.run {
keySet().firstOrNull { it.name == Category.CATEGORY_ATTRIBUTE.name }?.let { getAttribute(it) }
}

val id = variant.owner
return when (id) {
is ProjectComponentIdentifier -> project(id.projectPath)
is ModuleComponentIdentifier -> create(id.group, id.module, id.version)
else -> throw IllegalArgumentException("Can't convert $id to dependency")
}.let {
when (category) {
Category.REGULAR_PLATFORM -> platform(it)
Category.ENFORCED_PLATFORM -> enforcedPlatform(it)
Category.LIBRARY -> it
else -> throw IllegalStateException("Unexpected dependency type $category for id $id")
}
}
}

0 comments on commit 1ce27a3

Please sign in to comment.