@@ -19,19 +19,42 @@ dependencies {
1919 BuildUtils . addLabKeyDependency(project : project, config : " modules" , depProjectPath : BuildUtils . getPlatformModuleProjectPath(project. gradle, " pipeline" ), depProjectConfig : " published" , depExtension : " module" )
2020}
2121
22+ ConfigurableFileTree copyDestination = fileTree(" ./resources/web/jbrowseApp/" );
2223project. task(" copyJBrowse" ,
2324 type : Copy ,
2425 group : " Build" ,
2526 description : " Copy jbrowse app into webapp directory" ,
2627 { CopySpec copy ->
2728 copy. from fileTree(" ./node_modules/@gmod/jbrowse" ). exclude(' css/main.css' )
28- copy. into new File ( " ./resources/web/jbrowseApp/ " )
29+ copy. into copyDestination . getDir( )
2930 }
3031). doFirst({
3132 File f = project. file(' ./node_modules/@gmod/jbrowse' );
3233 if (! f. exists()){
3334 throw new GradleException (" Input source for copyJBrowse doesn't exist: " + f. getAbsolutePath())
3435 }
36+ }). onlyIf({
37+ // this is a very expensive step and the input should rarely change
38+ if (copyDestination. getDir(). exists()) {
39+ File firstModifiedCopiedFile = copyDestination. exclude(" ./resources/web/jbrowseApp/css/" ). sort {it. lastModified()}. first()
40+ File lastModifiedSourceFile = fileTree(' ./node_modules/@gmod/jbrowse' ). exclude(' package.json' ). sort {it. lastModified()}. last()
41+ if (firstModifiedCopiedFile. lastModified() < lastModifiedSourceFile. lastModified()) {
42+ println (" Source has been modified, need to copy again" )
43+ println (" Copy last copied: " + new Date (firstModifiedCopiedFile. lastModified()))
44+ println (" First modified file: " + firstModifiedCopiedFile. getPath())
45+
46+ println (" Source last modified: " + new Date (lastModifiedSourceFile. lastModified()))
47+ println (" Last modified file: " + lastModifiedSourceFile. getPath())
48+
49+ return true ;
50+ }
51+ else {
52+ println (" Up to date, no need to copy" )
53+ return false ;
54+ }
55+ }
56+
57+ return true ;
3558})
3659
3760project. task(" copyJBrowseCss" ,
0 commit comments