Skip to content

Instantly share code, notes, and snippets.

@nomisRev
Created July 28, 2021 11:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nomisRev/9f014d025fc83f296b32a6972748fc6a to your computer and use it in GitHub Desktop.
Save nomisRev/9f014d025fc83f296b32a6972748fc6a to your computer and use it in GitHub Desktop.
Main-jar & Test-jar from regular code
// PROJECT A
val testsConfig by configurations.creating {
extendsFrom(configurations["testImplementation"])
}
dependencies {
testsConfig(sourceSets.getByName("test").output)
}
// PROJECT B
testImplementation(project(":projectA", "testsConfig"))
// OR: for maven dependencies
val testsJar by tasks.creating(Jar::class) {
archiveClassifier.set("tests")
from(sourceSets.getByName("test").output)
} // similar JAR definitions for sources and testsSources
publishing {
publications {
create<MavenPublication>("maven") {
from(components["java"])
artifact(testsJar)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment