Skip to content

Replace buildDir with layout.buildDirectory and add an excludedModules property #621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ allprojects {
// Comment in to enable the tasks for owasp dependency checking
apply plugin: 'org.owasp.dependencycheck'
dependencyCheck {
outputDirectory = "${project.rootProject.buildDir}/reports/dependencyCheck/${project.path.replaceAll(':', '_').substring(1)}"
outputDirectory = project.rootProject.layout.buildDirectory.file("reports/dependencyCheck/${project.path.replaceAll(':', '_').substring(1)}").get().asFile
suppressionFile = "${project.rootProject.rootDir}/dependencyCheckSuppression.xml"
analyzers {
assemblyEnabled = false // Sets whether the .NET Assembly Analyzer should be used.
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ windowsProteomicsBinariesVersion=1.0
# The current version numbers for the gradle plugins.
artifactoryPluginVersion=4.31.9
gradleNodePluginVersion=3.5.1
gradlePluginsVersion=1.42.2
gradlePluginsVersion=1.43.0
owaspDependencyCheckPluginVersion=8.4.2
versioningPluginVersion=1.1.2

Expand Down
8 changes: 5 additions & 3 deletions gradle/settings/all.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,22 @@ import org.labkey.gradle.util.BuildUtils
/*
This settings file include all currently enlisted modules and API projects (JDBC, Java, SAS).
*/
List<String> excludedDirs = ["test"]
List<String> exclusions = ["test"]

if (hasProperty('gradleExcludeModuleDirs'))
{
excludedDirs.addAll("${gradleExcludeModuleDirs}".toLowerCase().split(","))
}
if (hasProperty('excludedModules'))
exclusions.addAll("${excludedModules}".split(","))

// Include ':server:embedded' unless explicitly excluded
if (!excludedDirs.contains("embedded"))
if (!exclusions.contains("embedded"))
{
include BuildUtils.getEmbeddedProjectPath(gradle)
}

BuildUtils.includeModules(this.settings, rootDir, ["server/modules"], excludedDirs, true)
BuildUtils.includeModules(this.settings, rootDir, ["server/modules"], exclusions, true)

// include the test distribution, which is used to create an artifact for TeamCity to pass around to the agents
include "${BuildUtils.getTestProjectPath(this.settings.gradle)}:distributions:teamcity"
Expand Down
6 changes: 5 additions & 1 deletion gradle/settings/distributions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,8 @@ import org.labkey.gradle.util.BuildUtils

apply from: 'all.gradle'

BuildUtils.includeModules(this.settings, rootDir, ["distributions"], [])
List<String> excludedModules = []
if (hasProperty('excludedModules'))
excludedModules.addAll("${excludedModules}".split(","))

BuildUtils.includeModules(this.settings, rootDir, ["distributions"], excludedModules)
9 changes: 7 additions & 2 deletions gradle/settings/ehr.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,13 @@ List<String> ehrModulesDirs = [
"server/modules/LabDevKitModules"
]

BuildUtils.includeModules(this.settings, rootDir, [BuildUtils.PLATFORM_MODULES_DIR, BuildUtils.COMMON_ASSAYS_MODULES_DIR], [])
BuildUtils.includeModules(this.settings, rootDir, ehrModulesDirs, [])
List<String> excludedModules = []
if (hasProperty('excludedModules'))
excludedModules.addAll("${excludedModules}".split(","))


BuildUtils.includeModules(this.settings, rootDir, [BuildUtils.PLATFORM_MODULES_DIR, BuildUtils.COMMON_ASSAYS_MODULES_DIR], excludedModules)
BuildUtils.includeModules(this.settings, rootDir, ehrModulesDirs, excludedModules)

include ":server:modules:snd"
include ":server:modules:tnprc_ehr"
Expand Down
8 changes: 4 additions & 4 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ project.tasks.register("tomcatLibsZip", Zip) {
zip.description = "produce jar file with jars to be deployed in \$CATALINA_HOME/lib"
zip.from project.configurations.tomcatJars.getAsFileTree()
zip.archiveBaseName.set("tomcat-libs")
zip.destinationDirectory = project.file(project.labkey.explodedModuleLibDir)
zip.destinationDirectory.set(project.file(project.labkey.explodedModuleLibDir))
}

configurations
Expand Down Expand Up @@ -210,8 +210,8 @@ tasks.register('createModule', CreateModule) {
// Each project that requires node will have its own downloaded version of node and npm, but for the symlinkNode
// task we need a single location, and one that works even when not building from source (Issue 35207)
project.node {
workDir = project.file("${project.rootProject.buildDir}/.node")
npmWorkDir = project.file("${project.rootProject.buildDir}/.node")
yarnWorkDir = project.file("${project.rootProject.buildDir}/.node")
workDir = BuildUtils.getRootBuildDirFile(project, ".node")
npmWorkDir = BuildUtils.getRootBuildDirFile(project, ".node")
yarnWorkDir = BuildUtils.getRootBuildDirFile(project, ".node")
}
project.tasks.named('deployApp').configure { dependsOn(project.tasks.npmSetup) }
19 changes: 12 additions & 7 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,28 @@ if (hasProperty("useEmbeddedTomcat"))

include BuildUtils.getMinificationProjectPath(gradle)

// A list of directory names or fully qualified module paths that correspond to modules to be excluded from configuration.
// Items may be individual module names (e.g. 'luminex'), module container names (e.g. 'customModules'), or paths (e.g., ':server:modules:commonAssays:flow')
// You must make sure to pass this list to the appropriate calls to `BuildUtils.includeModules`
List<String> excludedModules = []
if (hasProperty('excludedModules'))
{
excludedModules.addAll("${excludedModules}".split(","))
}
Comment on lines +110 to +113
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could the BuildUtils.include* methods automatically check the excludedModules property instead of having to check it in every settings file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried that, but this hasProperty method always returns null inside the Gradle plugin. Not sure why, but I didn't want to spend more time fighting it.


if (new File(getRootDir(), BuildUtils.convertPathToRelativeDir(BuildUtils.getPlatformProjectPath(gradle))).exists()
&& !hasProperty('excludeBaseModules'))
{
// The line below includes the set of modules for a minimally functional LabKey server
BuildUtils.includeBaseModules(this.settings)
BuildUtils.includeBaseModules(this.settings, excludedModules)

// Some test modules require base modules to build JSPs.
// TODO: Un-nest this 'if' once test modules can build without platform present.
if (new File(getRootDir(), BuildUtils.convertPathToRelativeDir(BuildUtils.getTestProjectPath(gradle))).exists()
&& !hasProperty('excludeTestModules'))
{
// The line below will include the server/testAutomation project as well as the server/testAutomation/modules projects
BuildUtils.includeTestModules(this.settings, rootDir)
BuildUtils.includeTestModules(this.settings, rootDir, excludedModules)
}
}
else if (new File(getRootDir(), BuildUtils.convertPathToRelativeDir(BuildUtils.getTestProjectPath(gradle))).exists())
Expand Down Expand Up @@ -149,10 +158,6 @@ else if (hasProperty('moduleSet'))
}
else
{
// A list of directory names that correspond to modules to be excluded from configuration.
// Items may be individual module names (e.g. 'luminex') or module container names (e.g. 'customModules')
// You must make sure to pass this list to the appropriate calls to `BuildUtils.includeModules`
List<String> excludedModules = []

// The line below recursively includes all modules in server/modules
BuildUtils.includeModules(this.settings, rootDir, [BuildUtils.SERVER_MODULES_DIR], excludedModules, true)
Expand Down Expand Up @@ -188,7 +193,7 @@ if (hasProperty('extraIncludes'))

if (hasProperty('extraModuleDirs'))
{
BuildUtils.includeModules(this.settings, rootDir, Arrays.asList("${extraModuleDirs}".split(",")), [])
BuildUtils.includeModules(this.settings, rootDir, Arrays.asList("${extraModuleDirs}".split(",")), excludedModules)
}

if (hasProperty('inheritedDistPath'))
Expand Down