Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
517 views
in Technique[技术] by (71.8m points)

java - Gradle exclude plugin in main project for specific subproject(s)

I am working on a larger project that contains many subprojects which are all build with gradle. Generally all projects are java projects, therefore in the main build.gradle script

allprojects {
    apply plugin: 'java'
}

is specified for all projects.

However I need to either remove the plugin for a certain subtree of projects or explicitly exclude the the projects from the plugin.

Heres a rough overview of the project layout

+ Main
+-- javaApplications
+-- javaLibs
+-- Android
+-----AndroidApps
+-----AndroidLibs

Android/* does not need the java plugin. What is the best solution to achieve this? Note: I cannot change the project structure.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This should do the trick (when placed in root build.gradle script)

configure(allprojects - project(':Android')) { //or ':Android:AndroidApps' not sure
    println "applying java plugin to $project"
    apply plugin: 'java'  
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...