Last active
June 18, 2020 17:14
-
-
Save ghale/e5ab42ea8d0914aaadea9669dfa22c20 to your computer and use it in GitHub Desktop.
Variant aware dependency management
This file contains hidden or 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
// Declare a new attribute type to use for selection | |
def usageAttribute = Attribute.of("com.adyen.usage", String) | |
// In both the producer and consumer, register the new attribute and set | |
// up a configuration associated to the attribute | |
subprojects { | |
dependencies.attributesSchema { | |
attribute(usageAttribute) | |
} | |
configurations { | |
web { | |
attributes { | |
attribute(usageAttribute, "web-resource") | |
} | |
} | |
} | |
} | |
project(':web-resources') { | |
apply plugin: 'java' | |
task webZip(type: Zip) { | |
from 'resources' | |
classifier 'web' | |
} | |
// Associate an artifact with the configuration | |
artifacts { | |
web webZip | |
} | |
} | |
project(':war') { | |
apply plugin: 'java' | |
dependencies { | |
// declare a dependency on the project in the configuration with the | |
// appropriate attribute | |
web project(':web-resources') | |
} | |
task copyWeb(type: Copy) { | |
from configurations.web | |
into layout.buildDir.dir('resources') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment