-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,501 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
|
||
class facade { | ||
|
||
def excludedItems = ["PC", "TeraEd"] | ||
|
||
def getGithubDefaultHome(Properties properties) { | ||
return properties.alternativeGithubHome ?: "MovingBlocks" | ||
} | ||
|
||
File targetDirectory = new File("facades") | ||
def itemType = "facade" | ||
|
||
// Facades currently do not care about dependencies | ||
String[] findDependencies(File targetDir) { | ||
return [] | ||
} | ||
|
||
def copyInTemplateFiles(File targetDir) { | ||
println "In copyInTemplateFiles for facade $targetDir.name - reviewing Gradle needs" | ||
File targetBuildGradle = new File(targetDir, 'build.gradle') | ||
if (!targetBuildGradle.exists()) { | ||
targetBuildGradle << new File('templates/facades.gradle').text | ||
} | ||
} | ||
|
||
/** | ||
* Filters the given items based on this item type's preferences | ||
* @param possibleItems A map of repos (possible items) and their descriptions (potential filter data) | ||
* @return A list containing only the items this type cares about | ||
*/ | ||
List filterItemsFromApi(Map possibleItems) { | ||
List itemList = [] | ||
|
||
// Facades only includes repos found to have a particular string snippet in their description | ||
itemList = possibleItems.findAll { | ||
it.value?.contains("Automation category: Terasology Facade") | ||
}.collect {it.key} | ||
|
||
return itemList | ||
} | ||
|
||
def refreshGradle(File targetDir) { | ||
// Copy in the template build.gradle for facades | ||
println "In refreshGradle for facade $targetDir - copying in a fresh build.gradle" | ||
File targetBuildGradle = new File(targetDir, 'build.gradle') | ||
targetBuildGradle.delete() | ||
targetBuildGradle << new File('templates/facades.gradle').text | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
|
||
class lib { | ||
|
||
def excludedItems = [] | ||
|
||
def getGithubDefaultHome(Properties properties) { | ||
return properties.alternativeGithubHome ?: "MovingBlocks" | ||
} | ||
|
||
File targetDirectory = new File("libs") | ||
def itemType = "library" | ||
|
||
// Libs currently do not care about dependencies | ||
String[] findDependencies(File targetDir) { | ||
return [] | ||
} | ||
|
||
// TODO: Libs don't copy anything in yet .. they might be too unique. Some may Gradle stuff but not all (like the Index) | ||
def copyInTemplateFiles(File targetDir) { | ||
|
||
} | ||
|
||
/** | ||
* Filters the given items based on this item type's preferences | ||
* @param possibleItems A map of repos (possible items) and their descriptions (potential filter data) | ||
* @return A list containing only the items this type cares about | ||
*/ | ||
List filterItemsFromApi(Map possibleItems) { | ||
List itemList = [] | ||
|
||
// Libs only includes repos found to have a particular string snippet in their description | ||
// TODO: Consideration for libraries - generic vs project specific? TeraMath could be used in DestSol etc ... | ||
itemList = possibleItems.findAll { | ||
it.value?.contains("Automation category: Terasology Library") | ||
}.collect {it.key} | ||
|
||
return itemList | ||
} | ||
|
||
def refreshGradle(File targetDir) { | ||
println "Skipping refreshGradle for lib $targetDir- they vary too much to use any Gradle templates" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
class meta { | ||
|
||
def excludedItems = ["metaterasology.github.io"] | ||
|
||
def getGithubDefaultHome(Properties properties) { | ||
// Note how metas use a different override property - since same name as the paired module they cannot live in same org | ||
return properties.alternativeGithubMetaHome ?: "MetaTerasology" | ||
} | ||
|
||
File targetDirectory = new File("metas") | ||
def itemType = "meta" | ||
|
||
// Meta modules currently do not care about dependencies | ||
String[] findDependencies(File targetDir) { | ||
return [] | ||
} | ||
|
||
def copyInTemplateFiles(File targetDir) { | ||
println "In copyInTemplateFiles for meta $targetDir.name - reviewing readme template" | ||
File targetReadme = new File(targetDir, 'README.md') | ||
if (!targetReadme.exists()) { | ||
def readmeText = new File('templates/metaREADME.markdown').text | ||
targetReadme << readmeText.replaceAll('MODULENAME', targetDir.name) | ||
} | ||
} | ||
|
||
/** | ||
* Filters the given items based on this item type's preferences | ||
* @param possibleItems A map of repos (possible items) and their descriptions (potential filter data) | ||
* @return A list containing only the items this type cares about | ||
*/ | ||
List filterItemsFromApi(Map possibleItems) { | ||
List itemList = [] | ||
|
||
// Meta modules just consider the item name and excludes those in a specific list | ||
itemList = possibleItems.findAll { | ||
!excludedItems.contains (it.key) | ||
}.collect {it.key} | ||
|
||
return itemList | ||
} | ||
|
||
def refreshGradle(File targetDir) { | ||
println "Skipping refreshGradle for meta module $targetDir - they don't Gradle" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
import groovy.json.JsonSlurper | ||
|
||
class module { | ||
def excludedItems = ["engine", "Index", "out", "build"] | ||
|
||
def getGithubDefaultHome(Properties properties) { | ||
return properties.alternativeGithubHome ?: "Terasology" | ||
} | ||
|
||
File targetDirectory = new File("modules") | ||
def itemType = "module" | ||
|
||
String[] findDependencies(File targetDir, boolean respectExcludedItems = true) { | ||
def foundDependencies = readModuleDependencies(new File(targetDir, "module.txt"), respectExcludedItems) | ||
println "Looked for dependencies, found: " + foundDependencies | ||
return foundDependencies | ||
} | ||
|
||
/** | ||
* Reads a given module info file to figure out which if any dependencies it has. Filters out any already retrieved. | ||
* This method is only for modules. | ||
* @param targetModuleInfo the target file to check (a module.txt file or similar) | ||
* @return a String[] containing the next level of dependencies, if any | ||
*/ | ||
String[] readModuleDependencies(File targetModuleInfo, boolean respectExcludedItems = true) { | ||
def qualifiedDependencies = [] | ||
if (!targetModuleInfo.exists()) { | ||
println "The module info file did not appear to exist - can't calculate dependencies" | ||
return qualifiedDependencies | ||
} | ||
def slurper = new JsonSlurper() | ||
def moduleConfig = slurper.parseText(targetModuleInfo.text) | ||
for (dependency in moduleConfig.dependencies) { | ||
if (respectExcludedItems && excludedItems.contains(dependency.id)) { | ||
println "Skipping listed dependency $dependency.id as it is in the exclude list (shipped with primary project)" | ||
} else { | ||
println "Accepting listed dependency $dependency.id" | ||
qualifiedDependencies << dependency.id | ||
} | ||
} | ||
return qualifiedDependencies | ||
} | ||
|
||
def copyInTemplateFiles(File targetDir) { | ||
// Copy in the template build.gradle for modules | ||
println "In copyInTemplateFiles for module $targetDir.name - copying in a build.gradle then next checking for module.txt" | ||
File targetBuildGradle = new File(targetDir, 'build.gradle') | ||
targetBuildGradle.delete() | ||
targetBuildGradle << new File('templates/build.gradle').text | ||
|
||
// Copy in the template module.txt for modules (if one doesn't exist yet) | ||
File moduleManifest = new File(targetDir, 'module.txt') | ||
if (!moduleManifest.exists()) { | ||
def moduleText = new File("templates/module.txt").text | ||
|
||
moduleManifest << moduleText.replaceAll('MODULENAME', targetDir.name) | ||
println "WARNING: the module ${targetDir.name} did not have a module.txt! One was created, please review and submit to GitHub" | ||
} | ||
|
||
// TODO: Copy in a module readme template soon | ||
// TODO : Add in the logback.groovy from engine\src\test\resources\logback.groovy ? Local dev only, Jenkins will use the one inside engine-tests.jar. Also add to .gitignore | ||
} | ||
|
||
/** | ||
* Filters the given items based on this item type's preferences | ||
* @param possibleItems A map of repos (possible items) and their descriptions (potential filter data) | ||
* @return A list containing only the items this type cares about | ||
*/ | ||
List filterItemsFromApi(Map possibleItems) { | ||
List itemList = [] | ||
|
||
// Modules just consider the item name and excludes those in a specific list | ||
itemList = possibleItems.findAll { | ||
!excludedItems.contains(it.key) | ||
}.collect { it.key } | ||
|
||
return itemList | ||
} | ||
|
||
def refreshGradle(File targetDir) { | ||
// Copy in the template build.gradle for modules | ||
if (!new File(targetDir, "module.txt").exists()) { | ||
println "$targetDir has no module.txt, it must not want a fresh build.gradle" | ||
return | ||
} | ||
println "In refreshGradle for module $targetDir - copying in a fresh build.gradle" | ||
File targetBuildGradle = new File(targetDir, 'build.gradle') | ||
targetBuildGradle.delete() | ||
targetBuildGradle << new File('templates/build.gradle').text | ||
} | ||
} |
Oops, something went wrong.