Gradle product taste in pure Gradle (not android gradle)

I want to create a java library for different clients using gradle. Is there something like products known from android in a β€œclean” gradle?

Thanks.

+5
source share
1 answer

The answer is yes, but you will have to use the new Gradle software model, which is very incubating. It will be a road full of pain as you will be the track blazer as I learned to use it for the C / Cpp project. Here is what your assembly looks like.

plugins { id 'jvm-component' id 'java-lang' } model { buildTypes { debug release } flavors { free paid } components { server(JvmLibrarySpec) { sources { java { if (flavor == flavors.paid) { // do something to your sources } if (builtType == buildTypes.debug) { // do something for debuging } dependencies { library 'core' } } } } core(JvmLibrarySpec) { dependencies { library 'commons' } } commons(JvmLibrarySpec) { api { dependencies { library 'collections' } } } collections(JvmLibrarySpec) } } 

References: 1) Java Software Model https://docs.gradle.org/current/userguide/java_software.html 2) Flavors https://docs.gradle.org/current/userguide/native_software.html Note. I'm not sure how well Java Java models are supported, I will do some testing and report back.

Update: this is doable, but is not currently supported by JvmLibrarySpec. I will try to post a more complete answer with an example of how to fulfill the user specification.

+1
source

Source: https://habr.com/ru/post/1243655/


All Articles