Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
740eb9e
Configure npm plugin to download binaries for the server project only
labkey-susanh Nov 4, 2024
27faadc
Remove configurations for yarn
labkey-susanh Nov 4, 2024
b2f28d1
Merge remote-tracking branch 'origin/develop' into fb_nmpSetupUpdates
labkey-susanh Nov 5, 2024
1e05f25
Gradle 8.11
labkey-susanh Nov 11, 2024
7c0dd1e
Remove use of deprecated ProjectDependency.getDependencyProject
labkey-susanh Nov 11, 2024
10a16d5
Gradle 8.11.1
labkey-susanh Dec 13, 2024
d912f5c
Remove use of deprecated dependencyProject
labkey-susanh Dec 13, 2024
1bea7ea
MODULES_DIR is not expected to have the DEPLOY_DIR prefix
labkey-susanh Dec 13, 2024
ff1e151
Add property to control whether to try to use a common NPM download
labkey-susanh Dec 13, 2024
6823516
Use task logger not project logger
labkey-susanh Dec 17, 2024
0f02fec
Better naming and add some info logging; fix project reference
labkey-susanh Dec 17, 2024
ef39419
Update release notes
labkey-susanh Dec 17, 2024
ea9ee34
Update release notes
labkey-susanh Dec 17, 2024
2d93866
call the method don't just reference it
labkey-susanh Dec 17, 2024
5d85d0d
Deprecate method instead of remove it for now to make version rollbac…
labkey-susanh Dec 20, 2024
5e5908b
Ah, syntax.
labkey-susanh Dec 20, 2024
0acd269
Gradle 8.12 and update to non-deprecated syntax in build file
labkey-susanh Dec 20, 2024
7d0f0a2
fix deployModulesDir
labkey-susanh Dec 20, 2024
3c598fe
conditionalize dependency
labkey-susanh Dec 20, 2024
e2911d6
remove deprecated syntax
labkey-susanh Dec 26, 2024
5eb5cf2
Remove `RestartTriggerTask` (for now).
labkey-susanh Dec 26, 2024
3739370
Use BuildUtils method
labkey-susanh Dec 26, 2024
22a92c2
Prepare for merge to develop
labkey-susanh Dec 27, 2024
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
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,23 @@ on how to do that, including how to develop and test locally and the versioning

## Release Notes

### 5.1.0-SNAPSHOT
### 6.1.0-SNAPSHOT
*Released*: TBD
(Earliest compatible LabKey version: 24.11)
-

### 6.0.0
*Released*: 27 December 2024
(Earliest compatible LabKey version: 24.11)
- Remove usage of deprecated `dependencyProject`
- Remove configuration of Yarn tasks and properties
- Fix directory for `deployModule` task
- Add optional properties `useServerNode` and `useOwnNode` for configuring `NpmRun` (incubating)
- If neither property is defined, each module using `npm` downloads its own copy of `node` and `npm` in the default `.gradle` directory for the module
- If `useServerNode` is defined, the download directory is specified as `<enlistment root>/.node`
- When `useServerNode` is defined, a module that defines `useOwnNode` will revert to the default behavior
- This is an incubating feature that requires more testing and troubleshooting to determine if it is always a viable option
- Remove `RestartTriggerTask` (for now). Its output declarations cause issues with the `DeployDistribution` task (at least)

### 5.0.0
*Released*: 5 November 2024
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ dependencies {
api "org.ajoberstar.grgit:grgit-gradle:${grgitGradleVersion}"
}

group 'org.labkey.build'
project.version = "5.1.0-SNAPSHOT"
group = 'org.labkey.build'
project.version = "6.1.0-SNAPSHOT"

gradlePlugin {
plugins {
Expand Down Expand Up @@ -169,7 +169,7 @@ if (hasProperty('artifactory_user') && hasProperty('artifactory_password'))
repositories {
if (project.version.contains("SNAPSHOT")) {
maven {
url "${artifactory_contextUrl}/plugins-snapshot-local"
url = "${artifactory_contextUrl}/plugins-snapshot-local"
credentials {
username = artifactory_user
password = artifactory_password
Expand All @@ -182,7 +182,7 @@ if (hasProperty('artifactory_user') && hasProperty('artifactory_password'))
}
else {
maven {
url "${artifactory_contextUrl}/plugins-release"
url = "${artifactory_contextUrl}/plugins-release"
credentials {
username = artifactory_user
password = artifactory_password
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class Distribution implements Plugin<Project>
if (it instanceof DefaultProjectDependency)
{
DefaultProjectDependency dep = (DefaultProjectDependency) it
TaskUtils.addOptionalTaskDependency(dep.dependencyProject, distTask, "module")
TaskUtils.addOptionalTaskDependency(project.project(dep.getPath()), distTask, "module")
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/main/groovy/org/labkey/gradle/plugin/FileModule.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -442,12 +442,12 @@ class FileModule implements Plugin<Project>
Dependency dep ->
if (dep instanceof ProjectDependency) {
ProjectDependency projectDep = (ProjectDependency) dep
if (shouldDoBuild(projectDep.dependencyProject, false)) {
BuildUtils.addLabKeyDependency(project: serverProject, config: 'modules', depProjectPath: projectDep.dependencyProject.getPath(), depProjectConfig: 'published', depExtension: 'module')
BuildUtils.addLabKeyDependency(project: serverProject, config: 'builtModules', depProjectPath: projectDep.dependencyProject.getPath(), depProjectConfig: 'published', depExtension: 'module')
if (shouldDoBuild(project.project(projectDep.getPath()), false)) {
BuildUtils.addLabKeyDependency(project: serverProject, config: 'modules', depProjectPath: projectDep.getPath(), depProjectConfig: 'published', depExtension: 'module')
BuildUtils.addLabKeyDependency(project: serverProject, config: 'builtModules', depProjectPath: projectDep.getPath(), depProjectConfig: 'published', depExtension: 'module')
} else {
serverProject.dependencies.add("modules", BuildUtils.getLabKeyArtifactName(project, projectDep.dependencyProject.getPath(), projectDep.version, "module"))
serverProject.dependencies.add("downloadedModules", BuildUtils.getLabKeyArtifactName(project, projectDep.dependencyProject.getPath(), projectDep.version, "module"))
serverProject.dependencies.add("modules", BuildUtils.getLabKeyArtifactName(project, projectDep.getPath(), projectDep.version, "module"))
serverProject.dependencies.add("downloadedModules", BuildUtils.getLabKeyArtifactName(project, projectDep.getPath(), projectDep.version, "module"))
}
} else {
serverProject.dependencies.add("modules", dep)
Expand Down
93 changes: 28 additions & 65 deletions src/main/groovy/org/labkey/gradle/plugin/NpmRun.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,22 @@ class NpmRun implements Plugin<Project>
// Version of npm to use.
npmVersion = project.npmVersion

if (project.hasProperty('yarnVersion'))
// Version of Yarn to use.
yarnVersion = project.yarnVersion

// Base URL for fetching node distributions (change if you have a mirror).
if (project.hasProperty('nodeRepo'))
distBaseUrl = project.nodeRepo

if (BuildUtils.useServerNode(project)) {
// The directory where Node.js is unpacked (when download is true)
workDir = project.file("${project.rootProject.projectDir}/.node")

// The directory where npm is installed (when a specific version is defined)
npmWorkDir = project.file("${project.rootProject.projectDir}/.node")
}

// If true, it will download node using above parameters.
// If false, it will try to use globally installed node.
download = project.hasProperty('nodeVersion') && project.hasProperty('npmVersion')
download = (BuildUtils.useOwnNode(project) || project.path.equals(BuildUtils.getServerProjectPath(project.gradle)))
&& project.hasProperty('nodeVersion') && project.hasProperty('npmVersion')

// Set the work directory where node_modules should be located
nodeProjectDir = project.file("${project.projectDir}")
Expand All @@ -97,52 +102,6 @@ class NpmRun implements Plugin<Project>
}
}

private static void addYarnTasks(Project project)
{
project.tasks.register("yarnRunClean")
{Task task ->
task.group = GroupNames.YARN
task.description = "Runs 'yarn run ${project.npmRun.clean}'"
task.dependsOn "yarn_run_${project.npmRun.clean}"
}
TaskUtils.configureTaskIfPresent(project, 'clean', { dependsOn(project.tasks.yarnRunClean) })

def yarnRunBuildProd = project.tasks.register("yarnRunBuildProd")
{Task task ->
task.group = GroupNames.YARN
task.description = "Runs 'yarn run ${project.npmRun.buildProd}'"
task.dependsOn "yarn_install"
task.dependsOn "yarn_run_${project.npmRun.buildProd}"
task.mustRunAfter "yarn_install"
}
configureBuildTask(project.tasks.named('yarnRunBuildProd'))
configureBuildTask(project.tasks.named("yarn_run_${project.npmRun.buildProd}"))

def yarnRunBuild = project.tasks.register("yarnRunBuild")
{Task task ->
task.group = GroupNames.YARN
task.description ="Runs 'yarn run ${project.npmRun.buildDev}'"
task.dependsOn "yarn_install"
task.dependsOn "yarn_run_${project.npmRun.buildDev}"
task.mustRunAfter "yarn_install"
}
configureBuildTask(project.tasks.named('yarnRunBuild'))
configureBuildTask(project.tasks.named("yarn_run_${project.npmRun.buildDev}"))

def runCommand = LabKeyExtension.isDevMode(project) ? yarnRunBuild : yarnRunBuildProd
TaskUtils.configureTaskIfPresent(project, "module", { dependsOn(runCommand) })
TaskUtils.configureTaskIfPresent(project, "processResources", { dependsOn(runCommand) })
TaskUtils.configureTaskIfPresent(project, "processModuleResources", { dependsOn(runCommand) })
TaskUtils.configureTaskIfPresent(project, "processWebappResources", { dependsOn(runCommand) })

project.tasks.named("yarn_install").configure {Task task ->
task.inputs.file project.file(NPM_PROJECT_FILE)
if (project.file(NPM_PROJECT_LOCK_FILE).exists())
task.inputs.file project.file(NPM_PROJECT_LOCK_FILE)
}
project.tasks.named("yarn_install").configure {outputs.upToDateWhen { project.file(NODE_MODULES_DIR).exists() } }
}

private static void addNpmTasks(Project project)
{
project.tasks.register("npmRunClean")
Expand Down Expand Up @@ -170,10 +129,22 @@ class NpmRun implements Plugin<Project>
task.description ="Runs 'npm run ${project.npmRun.buildDev}'"
task.dependsOn "npm_run_${project.npmRun.buildDev}"
task.mustRunAfter "npmInstall"
task.doFirst({
task.logger.info("npmWorkDir ${project.node.npmWorkDir.get()}")
task.logger.info("workDir ${project.node.workDir.get()}")
task.logger.info("resolvedNodeDir ${project.node.resolvedNodeDir.get()}")
})
}

configureBuildTask(project.tasks.named('npmRunBuild'))
configureBuildTask(project.tasks.named("npm_run_${project.npmRun.buildDev}"))
if (BuildUtils.useServerNode(project) && project.path !== BuildUtils.getServerProject(project).path) {
project.tasks.named('npmSetup').configure
{
Task task ->
task.dependsOn(BuildUtils.getServerProject(project).tasks.npmSetup)
}
}

project.tasks.named('npmInstall').configure
{Task task ->
Expand All @@ -183,6 +154,9 @@ class NpmRun implements Plugin<Project>
// Specify legacy peer dependency mode for npm v7+
task.args = ["--legacy-peer-deps"]
task.outputs.upToDateWhen { project.file(NODE_MODULES_DIR).exists() }
if (BuildUtils.useServerNode(project)) {
task.dependsOn(BuildUtils.getServerProject(project).tasks.npmSetup)
}
}

def runCommand = LabKeyExtension.isDevMode(project) && !project.hasProperty('useNpmProd') ? npmRunBuild : npmRunBuildProd
Expand All @@ -192,19 +166,11 @@ class NpmRun implements Plugin<Project>
TaskUtils.configureTaskIfPresent(project, "processWebappResources", { dependsOn(runCommand) })
}

static boolean useYarn(Project project)
{
return project.hasProperty("yarnVersion") && !project.file(NPM_PROJECT_LOCK_FILE).exists()
}

private static void addTasks(Project project)
{
if (project.file(NPM_PROJECT_FILE).exists())
{
if (useYarn(project))
addYarnTasks(project)
else
addNpmTasks(project)
addNpmTasks(project)

project.tasks.register("cleanNodeModules", Delete) {
Delete task ->
Expand All @@ -214,10 +180,7 @@ class NpmRun implements Plugin<Project>
if (project.file(NODE_MODULES_DIR).exists())
delete.delete(project.file(NODE_MODULES_DIR))
})
if (useYarn(project))
task.mustRunAfter(project.tasks.yarnRunClean)
else
task.mustRunAfter(project.tasks.npmRunClean)
task.mustRunAfter(project.tasks.npmRunClean)
}
}

Expand All @@ -229,7 +192,7 @@ class NpmRun implements Plugin<Project>
List<String> nodeProjects = []
project.allprojects({Project p ->
if (p.getPlugins().hasPlugin(NpmRun.class))
nodeProjects.add("${p.path} (${useYarn(p) ? 'yarn' : 'npm'})")
nodeProjects.add(p.path)
})
if (nodeProjects.size() == 0)
println("No projects found containing ${NPM_PROJECT_FILE}")
Expand Down
17 changes: 8 additions & 9 deletions src/main/groovy/org/labkey/gradle/plugin/ServerDeploy.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ import java.nio.file.Paths
class ServerDeploy implements Plugin<Project>
{
public static final String DEPLOY_DIR = "deploy"
public static final String MODULES_DIR = "${DEPLOY_DIR}/modules"
public static final String WEBAPP_DIR = "${DEPLOY_DIR}/labkeyWebapp"
public static final String PIPELINE_DIR = "${DEPLOY_DIR}/pipelineLib"
public static final String BIN_DIR = "${DEPLOY_DIR}/bin"
public static final String MODULES_DIR = "modules"
public static final String DEPLOY_MODULES_DIR = "${DEPLOY_DIR}/${MODULES_DIR}"
public static final String DEPLOY_WEBAPP_DIR = "${DEPLOY_DIR}/labkeyWebapp"
public static final String DEPLOY_PIPELINE_DIR = "${DEPLOY_DIR}/pipelineLib"
public static final String DEPLOY_BIN_DIR = "${DEPLOY_DIR}/bin"
public static final String STAGING_DIR = "staging"
public static final String STAGING_MODULES_DIR = "${STAGING_DIR}/modules/"
public static final String STAGING_PIPELINE_DIR = "${STAGING_DIR}/pipelineLib"
Expand Down Expand Up @@ -143,12 +144,10 @@ class ServerDeploy implements Plugin<Project>
task.group = GroupNames.DEPLOY
task.description = "Make a symbolic link to the npm directory for use in PATH environment variable"
task.doFirst({
// we'll need to support both yarn and npm, so link them both if both are present.
if (project.hasProperty('npmVersion') && project.hasProperty('npmWorkDirectory'))
linkBinaries(project, "npm", project.npmVersion, project.npmWorkDirectory)
if (project.hasProperty('yarnVersion') && project.hasProperty('yarnWorkDirectory'))
linkBinaries(project, "yarn", project.yarnVersion, project.yarnWorkDirectory)
})
task.dependsOn(project.tasks.npmSetup)
}
project.tasks.symlinkNode.notCompatibleWithConfigurationCache("References project properties. Need to add task class with input properties")
project.tasks.named('deployApp').configure {dependsOn(project.tasks.symlinkNode)}
Expand Down Expand Up @@ -319,7 +318,7 @@ class ServerDeploy implements Plugin<Project>

Path pmLinkPath = Paths.get("${linkContainer.getPath()}/${packageMgr}")
String pmDirName = "${packageMgr}-v${version}"
Path pmTargetPath = Paths.get(BuildUtils.getBuildDirFile(pmLinkProject, "${workDirectory}/${pmDirName}").getPath())
Path pmTargetPath = Paths.get(pmLinkProject.file( "${workDirectory}/${pmDirName}").getPath())

if (!Files.isSymbolicLink(pmLinkPath) || !Files.readSymbolicLink(pmLinkPath).getFileName().toString().equals(pmDirName))
{
Expand All @@ -334,7 +333,7 @@ class ServerDeploy implements Plugin<Project>
Path nodeLinkPath = Paths.get("${linkContainer.getPath()}/node")
if (!Files.isSymbolicLink(nodeLinkPath) || !Files.readSymbolicLink(nodeLinkPath).getFileName().toString().startsWith(nodeFilePrefix))
{
File nodeDir = BuildUtils.getBuildDirFile(pmLinkProject, project.nodeWorkDirectory)
File nodeDir = pmLinkProject.file(project.nodeWorkDirectory)
File[] nodeFiles = nodeDir.listFiles({ File file -> file.name.startsWith(nodeFilePrefix) } as FileFilter)
if (nodeFiles != null && nodeFiles.length > 0)
{
Expand Down
4 changes: 2 additions & 2 deletions src/main/groovy/org/labkey/gradle/plugin/TeamCity.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ class TeamCity extends Tomcat
if (!extension.isValidForTestRun())
throw new GradleException("TeamCity configuration problem(s): ${extension.validationMessages.join('; ')}")

project.logger.info("teamcity.build.branch.is_default: ${extension.getTeamCityProperty('teamcity.build.branch.is_default')}")
project.logger.info("teamcity.build.branch: ${extension.getTeamCityProperty('teamcity.build.branch')}")
task.logger.info("teamcity.build.branch.is_default: ${extension.getTeamCityProperty('teamcity.build.branch.is_default')}")
task.logger.info("teamcity.build.branch: ${extension.getTeamCityProperty('teamcity.build.branch')}")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ class ServerDeployExtension
{
Map<String, String> foundModules = new HashMap<>();

@Deprecated(forRemoval=true)
static String getServerDeployDirectory(Project project)
{
return getServerDeployDirectoryPath(project)
}

static String getServerDeployDirectoryPath(Project project)
{
return BuildUtils.getRootBuildDirFile(project, ServerDeploy.DEPLOY_DIR).path
Expand Down
10 changes: 5 additions & 5 deletions src/main/groovy/org/labkey/gradle/task/DeployApp.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@ abstract class DeployApp extends DeployAppBase
final abstract DirectoryProperty stagingPipelineJarDir = BuildUtils.getRootBuildDirectoryProperty(project, ServerDeploy.STAGING_PIPELINE_DIR)

@OutputDirectory
final abstract DirectoryProperty deployModulesDir = BuildUtils.getRootBuildDirectoryProperty(project, ServerDeploy.MODULES_DIR)
final abstract DirectoryProperty deployModulesDir = BuildUtils.getRootBuildDirectoryProperty(project, ServerDeploy.DEPLOY_MODULES_DIR)

// We declare this as an output so it will be created by this task, even though not actually populated here
@OutputDirectory
final abstract DirectoryProperty deployWebappDir = BuildUtils.getRootBuildDirectoryProperty(project, ServerDeploy.WEBAPP_DIR)
final abstract DirectoryProperty deployWebappDir = BuildUtils.getRootBuildDirectoryProperty(project, ServerDeploy.DEPLOY_WEBAPP_DIR)

@OutputDirectory
final abstract DirectoryProperty deployPipelineLibDir = BuildUtils.getRootBuildDirectoryProperty(project, ServerDeploy.PIPELINE_DIR)
final abstract DirectoryProperty deployPipelineLibDir = BuildUtils.getRootBuildDirectoryProperty(project, ServerDeploy.DEPLOY_PIPELINE_DIR)

@OutputDirectory
final abstract DirectoryProperty deployBinDir = BuildUtils.getRootBuildDirectoryProperty(project, ServerDeploy.BIN_DIR)
final abstract DirectoryProperty deployBinDir = BuildUtils.getRootBuildDirectoryProperty(project, ServerDeploy.DEPLOY_BIN_DIR)

@TaskAction
void action()
{
deployModules()
deployPipelineJars()
deployPlatformBinaries(deployBinDir.get().asFile)
updateRestartTriggerFile()
BuildUtils.updateRestartTriggerFile(project)
}

private void deployModules()
Expand Down
Loading