I am trying to implement below hierarchy in Ant:
ParentProject
build.xml
RuntimeFolder_1
build.xml
RuntimeFolder_2
build.xml
RuntimeFolder_n
build.xml
Here, When I build ParentFolder build.xml, it should iterate all child folders and build them. A user can add any number of run time folders. Also, I should able to build RuntimeFolder_1...RuntimeFolder_n individually. Does someone know how I can do this?
I know the OP requested Ant but he has expressed an interest in a Gradle solution which might look like
build.gradle
settings.gradle
project1/
build.gradle
project2/
build.gradle
project3/
build.gradle
Your settings.gradle
might look like
rootDir.listFiles().each {
if (new File(it, 'build.gradle').exists()) {
include ":$it.name"
}
}
You'd then apply the java
plugin to each subproject. This could be done programmatically in the root build.gradle
subprojects {
apply plugin: 'java'
}
Or in each of the subproject\\build.gradle
apply plugin: 'java'
For further reading see multi project builds and the java plugin
For this, we can use subant: http://ant.apache.org/manual/Tasks/subant.html
Below is the example:
Parent build.xml will contain:
<macrodef name="iterate">
<attribute name="target"/>
<sequential>
<subant target="@{target}">
<fileset dir="modules" includes="*/build.xml"/>
</subant>
</sequential>
</macrodef>
<target name="compile">
<iterate target="compile"/>
</target>
Inside folder build.xml will contain those targets.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.