Created
July 28, 2021 11:14
-
-
Save nomisRev/9f014d025fc83f296b32a6972748fc6a to your computer and use it in GitHub Desktop.
Main-jar & Test-jar from regular code
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
// 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