@@ -23,10 +23,13 @@ import org.gradle.api.DefaultTask
2323import org.gradle.api.GradleException
2424import org.gradle.api.Project
2525import org.gradle.api.file.FileTree
26+ import org.gradle.api.tasks.CacheableTask
2627import org.gradle.api.tasks.InputFiles
2728import org.gradle.api.tasks.Internal
2829import org.gradle.api.tasks.OutputDirectories
2930import org.gradle.api.tasks.OutputFiles
31+ import org.gradle.api.tasks.PathSensitive
32+ import org.gradle.api.tasks.PathSensitivity
3033import org.gradle.api.tasks.TaskAction
3134import org.labkey.gradle.plugin.NpmRun
3235import 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
4650class 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()} " )
0 commit comments