Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to apply java plugin too all projects except one special projects?

Tags:

gradle

If I have a multiple projects in gradle, there are project1 .. project10. And all depends on java plugin except project10. How to do that?

I am planning to use subprojects but then it will apply to project10 as well. so how exclude it?

like image 865
Daniel Wu Avatar asked Nov 28 '14 02:11

Daniel Wu


People also ask

What is the use of multi-project builds?

With multi-project builds this becomes possible because each subproject contains its own source code and configuration. Not only can you create a different jar file based on different source code, but you could just as easily setup a subproject to compile Kotlin, Scala, Groovy, or even C++.

Which are the two types of plugins in Gradle?

There are two general types of plugins in Gradle, binary plugins and script plugins.

What is the purpose of a Gradle Java plugin?

The Java Gradle Plugin development plugin can be used to assist in the development of Gradle plugins. It automatically applies the Java Library plugin, adds the gradleApi() dependency to the api configuration and performs validation of plugin metadata during jar task execution.


2 Answers

Haven't tested it but seems like you will be able to filter by name:

Subproject configuration - base on the Filtering by name section, you should be able to do something like this.

configure(subprojects.findAll {it.name != 'project10'}) {
    apply plugin: 'java'
}
like image 69
evanwong Avatar answered Oct 13 '22 20:10

evanwong


Except several projects:

configure(subprojects.findAll {
    !listOf("project2", "project5").contains(it.name)
}) {
    apply plugin: 'java'
}

On Kotlin DSL:

configure(subprojects.filter {
    !listOf("project2", "project5").contains(it.name)
}) {
    apply(plugin = "org.jetbrains.kotlin.plugin.spring")
}
like image 26
Stanislau Listratsenka Avatar answered Oct 13 '22 20:10

Stanislau Listratsenka