Skip to content

Commit 187848a

Browse files
Issue 1090: Update annotations on custom Tasks to enable strict plugin validation (#244)
1 parent 87148af commit 187848a

39 files changed

Lines changed: 173 additions & 47 deletions

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,13 @@ If you are making changes to the plugins, please see the [internal docs](https:/
1212
on how to do that, including how to develop and test locally and the versioning information.
1313

1414
## Release Notes
15-
### 8.2.0-SNAPSHOT
16-
*Released*: TBD
15+
16+
### 8.2.0
17+
*Released*: 11 May 2026
1718
(Earliest compatible LabKey version: 26.5.0)
19+
- Add `BuildUtils.hasArtifactoryProperties` method for brevity
20+
- Add cacheability annotations to tasks so they work with stricter plugin validation
21+
- Update to Gradle 9.5.0
1822

1923
### 8.1.0
2024
*Released*: 22 April 2026

build.gradle

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,7 @@ dependencies {
4343
}
4444

4545
group = 'org.labkey.build'
46-
project.version = "8.2.0-SNAPSHOT"
47-
48-
// Stricter plugin validation was added in 9.4.0. Disable it for now. TODO: Address complaints and remove.
49-
tasks.validatePlugins {
50-
enableStricterValidation = false
51-
}
46+
project.version = "8.3.0-SNAPSHOT"
5247

5348
gradlePlugin {
5449
plugins {

gradle/wrapper/gradle-wrapper.jar

3.25 KB
Binary file not shown.

gradlew

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/groovy/org/labkey/gradle/task/Bootstrap.groovy

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@
1515
*/
1616
package org.labkey.gradle.task
1717

18+
import org.gradle.api.tasks.UntrackedTask
1819
import org.labkey.gradle.util.DatabaseProperties
1920

21+
@UntrackedTask(because="Should always be run")
2022
abstract class Bootstrap extends DoThenSetup
2123
{
2224
@Override

src/main/groovy/org/labkey/gradle/task/CheckForVersionConflicts.groovy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,19 @@ import org.gradle.api.file.FileCollection
2121
import org.gradle.api.provider.Property
2222
import org.gradle.api.tasks.Input
2323
import org.gradle.api.tasks.InputFiles
24+
import org.gradle.api.tasks.PathSensitive
25+
import org.gradle.api.tasks.PathSensitivity
2426
import org.gradle.api.tasks.TaskAction
27+
import org.gradle.api.tasks.UntrackedTask
2528
import org.labkey.gradle.util.BuildUtils
2629

2730
import java.util.regex.Matcher
2831

2932
/**
3033
* Checks for conflicts that may exist between a file collection and the files in an existing directory
3134
*/
32-
class CheckForVersionConflicts extends DefaultTask
35+
@UntrackedTask(because="Should always be run")
36+
class CheckForVersionConflicts extends DefaultTask
3337
{
3438
// GH Issue 1015: We are using milestone versions of spring-ai jars, which use classifiers like -M2 to distinguish the different versions.
3539
// We want to have the later milestones replace the earlier ones, so we want to exclude the milestone classifier from the name when
@@ -64,7 +68,7 @@ class CheckForVersionConflicts extends DefaultTask
6468
project.hasProperty('versionConflictAction') ? ConflictAction.valueOf((String) project.property('versionConflictAction')) : ConflictAction.fail)
6569

6670
/** The collection of files to check for. Usually this will come from a configuration. **/
67-
@InputFiles
71+
@InputFiles @PathSensitive(PathSensitivity.RELATIVE)
6872
FileCollection collection
6973

7074
/** The name of a task to run if conflicts are found that will resolve the conflict (presumably by cleaning out the directory) **/

src/main/groovy/org/labkey/gradle/task/ClientLibsCompress.groovy

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@ import org.gradle.api.DefaultTask
2323
import org.gradle.api.GradleException
2424
import org.gradle.api.Project
2525
import org.gradle.api.file.FileTree
26+
import org.gradle.api.tasks.CacheableTask
2627
import org.gradle.api.tasks.InputFiles
2728
import org.gradle.api.tasks.Internal
2829
import org.gradle.api.tasks.OutputDirectories
2930
import org.gradle.api.tasks.OutputFiles
31+
import org.gradle.api.tasks.PathSensitive
32+
import org.gradle.api.tasks.PathSensitivity
3033
import org.gradle.api.tasks.TaskAction
3134
import org.labkey.gradle.plugin.NpmRun
3235
import org.labkey.gradle.plugin.extension.LabKeyExtension
@@ -43,19 +46,24 @@ import java.util.stream.Collectors
4346
/**
4447
* Class for compressing javascript and css files using the yuicompressor classes.
4548
*/
49+
@CacheableTask
4650
class ClientLibsCompress extends DefaultTask
4751
{
4852
public static final String LIB_XML_EXTENSION = ".lib.xml"
4953

50-
protected File workingDir = new File((String) project.labkey.explodedModuleWebDir)
51-
5254
// This returns the libXml files from the project directory (the actual input files)
5355
@InputFiles
56+
@PathSensitive(PathSensitivity.RELATIVE)
5457
FileTree xmlFiles
5558
private List<File> inputFiles = null
5659
private List<File> outputFiles = null
5760
private List<File> outputDirs = null
5861

62+
@Internal
63+
String getWorkingDirPath() {
64+
return new File((String) project.labkey.explodedModuleWebDir).getAbsolutePath()
65+
}
66+
5967
/**
6068
* Creates a map between the individual .lib.xml files and the importers used to parse these files and
6169
* extract the css and javascript files that are referenced.
@@ -103,6 +111,7 @@ class ClientLibsCompress extends DefaultTask
103111
* @return list of all the .lib.xml files and the (internal) files referenced in the .lib.xml files
104112
*/
105113
@InputFiles
114+
@PathSensitive(PathSensitivity.RELATIVE)
106115
List<File> getInputFiles()
107116
{
108117
if (inputFiles == null)
@@ -139,7 +148,7 @@ class ClientLibsCompress extends DefaultTask
139148
getImporterMap().entrySet().each { Map.Entry<File, XmlImporter> entry ->
140149
// The output file will be in the working directory not in the source directory used when parsing the file.
141150
String fileName = entry.key.getAbsolutePath()
142-
fileName = fileName.replace(entry.value.sourceDir.getAbsolutePath(), workingDir.getAbsolutePath())
151+
fileName = fileName.replace(entry.value.sourceDir.getAbsolutePath(), getWorkingDirPath())
143152
File workingFile = project.file(fileName)
144153
if (entry.value.getCssFiles().size() > 0)
145154
{
@@ -306,7 +315,7 @@ class ClientLibsCompress extends DefaultTask
306315
File cssMinFile = null
307316

308317
File sourceDir = getSourceDir(xmlFile)
309-
File workingFile = new File(xmlFile.getAbsolutePath().replace(sourceDir.getAbsolutePath(), workingDir.getAbsolutePath()))
318+
File workingFile = new File(xmlFile.getAbsolutePath().replace(sourceDir.getAbsolutePath(), getWorkingDirPath()))
310319

311320
File packageJson = new File(getMinificationWorkingDir(xmlFile), "package.json")
312321
project.logger.info("Creating ${packageJson} for ${xmlFile.getAbsolutePath()}")

src/main/groovy/org/labkey/gradle/task/CopyAndInstallRPackage.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,21 @@ import org.gradle.api.file.CopySpec
44
import org.gradle.api.file.DuplicatesStrategy
55
import org.gradle.api.file.FileSystemOperations
66
import org.gradle.api.tasks.InputDirectory
7+
import org.gradle.api.tasks.PathSensitive
8+
import org.gradle.api.tasks.PathSensitivity
79
import org.gradle.api.tasks.TaskAction
810
import org.gradle.api.tasks.TaskExecutionException
11+
import org.gradle.work.DisableCachingByDefault
912

1013
import javax.inject.Inject
1114

15+
@DisableCachingByDefault(because="Does only file copying")
1216
abstract class CopyAndInstallRPackage extends InstallRPackage
1317
{
1418
@Inject abstract FileSystemOperations getFs()
1519

1620
@InputDirectory
21+
@PathSensitive(PathSensitivity.RELATIVE)
1722
File packageLocation
1823

1924
@TaskAction

src/main/groovy/org/labkey/gradle/task/CopyJsp.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,24 @@ package org.labkey.gradle.task
33
import org.gradle.api.DefaultTask
44
import org.gradle.api.file.DirectoryProperty
55
import org.gradle.api.file.FileSystemOperations
6+
import org.gradle.api.tasks.CacheableTask
67
import org.gradle.api.tasks.InputDirectory
78
import org.gradle.api.tasks.OutputDirectory
9+
import org.gradle.api.tasks.PathSensitive
10+
import org.gradle.api.tasks.PathSensitivity
811
import org.gradle.api.tasks.TaskAction
912

1013
import javax.inject.Inject
1114

15+
@CacheableTask
1216
abstract class CopyJsp extends DefaultTask
1317
{
1418
public static final String WEBAPP_DIR = "jspWebappDir/webapp"
1519

1620
@Inject abstract FileSystemOperations getFs()
1721

1822
@InputDirectory
23+
@PathSensitive(PathSensitivity.RELATIVE)
1924
final abstract DirectoryProperty srcDir = project.objects.directoryProperty().convention(project.layout.projectDirectory.dir('src'))
2025

2126
@OutputDirectory

src/main/groovy/org/labkey/gradle/task/CreateJsDocs.groovy

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,26 @@ import org.gradle.api.file.Directory
2121
import org.gradle.api.file.DirectoryProperty
2222
import org.gradle.api.provider.ListProperty
2323
import org.gradle.api.provider.Property
24+
import org.gradle.api.tasks.CacheableTask
25+
import org.gradle.api.tasks.Classpath
2426
import org.gradle.api.tasks.Input
2527
import org.gradle.api.tasks.InputDirectory
2628
import org.gradle.api.tasks.OutputDirectory
29+
import org.gradle.api.tasks.PathSensitive
30+
import org.gradle.api.tasks.PathSensitivity
2731
import org.gradle.api.tasks.TaskAction
2832
import org.gradle.process.ExecOperations
2933
import org.labkey.gradle.plugin.XsdDoc
3034

3135
import javax.inject.Inject
3236

37+
@CacheableTask
3338
abstract class CreateJsDocs extends DefaultTask
3439
{
3540
@Inject abstract ExecOperations getExec()
3641

3742
@InputDirectory
43+
@PathSensitive(PathSensitivity.RELATIVE)
3844
final abstract DirectoryProperty templateDir = project.objects.directoryProperty().convention(
3945
project.rootProject.layout.projectDirectory.dir("tools/jsdoc-toolkit/templates/jsdoc_substituted")
4046
)

0 commit comments

Comments
 (0)