gradle(modules): skip modules without modules.txt
and remove some redundant directory-setting
+/*
+ * Copyright 2020 MovingBlocks
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
// This magically allows subdirs in this subproject to themselves become sub-subprojects in a proper tree structure
new File(rootDir, 'modules').eachDir { possibleSubprojectDir ->
- def subprojectName = 'modules:' + possibleSubprojectDir.name
- //println "Gradle is reviewing module $subprojectName for inclusion as a sub-project"
+ def subprojectName = ':modules:' + possibleSubprojectDir.name
File buildFile = new File(possibleSubprojectDir, "build.gradle")
- if (buildFile.exists()) {
- println "Module $subprojectName has a build file so counting it complete and including it"
- include subprojectName
- def subprojectPath = ':' + subprojectName
- def subproject = project(subprojectPath)
- subproject.projectDir = possibleSubprojectDir
- } else {
- println "***** WARNING: Found a module without a build.gradle, corrupt dir? NOT including $subprojectName *****"
+ File moduleTxt = new File(possibleSubprojectDir, "module.txt")
+ if (!buildFile.exists()) {
+ logger.warn("***** WARNING: Found a module without a build.gradle, corrupt dir? NOT including $subprojectName *****")
+ return
}
+ if (!moduleTxt.exists()) {
+ logger.warn("Module $subprojectName has build.gradle, but no module.txt? NOT including $subprojectName")
+ return
+ }
+ logger.info("Module {} has a build file so counting it complete and including it", subprojectName)
+ include subprojectName
}
