@@ -18,4 +18,87 @@ dependencies {
1818 BuildUtils . addLabKeyDependency(project : project, config : " modules" , depProjectPath : " :server:modules:LabDevKitModules:LDK" , depProjectConfig : " published" , depExtension : " module" )
1919 BuildUtils . addLabKeyDependency(project : project, config : " modules" , depProjectPath : " :server:modules:DiscvrLabKeyModules:SequenceAnalysis" , depProjectConfig : " published" , depExtension : " module" )
2020 BuildUtils . addLabKeyDependency(project : project, config : " modules" , depProjectPath : BuildUtils . getPlatformModuleProjectPath(project. gradle, " pipeline" ), depProjectConfig : " published" , depExtension : " module" )
21- }
21+ }
22+
23+ ConfigurableFileTree copyDestination = fileTree(" ./resources/web/jbrowseApp/" );
24+ project. task(" copyJBrowse" ,
25+ type : Copy ,
26+ group : " Build" ,
27+ description : " Copy jbrowse app into webapp directory" ,
28+ { CopySpec copy ->
29+ copy. from fileTree(" ./node_modules/@gmod/jbrowse" ). exclude(' css/main.css' )
30+ copy. into copyDestination. getDir()
31+ }
32+ ). doFirst({
33+ File f = project. file(' ./node_modules/@gmod/jbrowse' );
34+ if (! f. exists()){
35+ throw new GradleException (" Input source for copyJBrowse doesn't exist: " + f. getAbsolutePath())
36+ }
37+ }). onlyIf({
38+ // this is a very expensive step and the input should rarely change
39+ if (copyDestination. getDir(). exists()) {
40+ List<File > copiedFiles = copyDestination. exclude(" ./resources/web/jbrowseApp/css/" ). sort {it. lastModified()};
41+ if (copiedFiles. isEmpty()) {
42+ return true ;
43+ }
44+
45+ File firstModifiedCopiedFile = copiedFiles. first()
46+ File lastModifiedSourceFile = fileTree(' ./node_modules/@gmod/jbrowse' ). exclude(' package.json' ). sort {it. lastModified()}. last()
47+ if (firstModifiedCopiedFile. lastModified() < lastModifiedSourceFile. lastModified()) {
48+ println (" Source has been modified, need to copy again" )
49+ println (" Copy last copied: " + new Date (firstModifiedCopiedFile. lastModified()))
50+ println (" First modified file: " + firstModifiedCopiedFile. getPath())
51+
52+ println (" Source last modified: " + new Date (lastModifiedSourceFile. lastModified()))
53+ println (" Last modified file: " + lastModifiedSourceFile. getPath())
54+
55+ return true ;
56+ }
57+ else {
58+ println (" Up to date, no need to copy" )
59+ return false ;
60+ }
61+ }
62+
63+ return true ;
64+ })
65+
66+ project. task(" copyJBrowseCss" ,
67+ type : Copy ,
68+ group : " Build" ,
69+ description : " Copy jbrowse main.css into webapp directory" ,
70+ { CopySpec copy ->
71+ copy. from new File (" ./webpack/main.css" )
72+ copy. into new File (" ./resources/web/jbrowseApp/css/" )
73+ }
74+ ). doFirst({
75+ File f = project. file(' ./resources/web/jbrowseApp/index.html' );
76+ if (! f. exists())
77+ {
78+ throw new GradleException (" copyJBrowse was not successful. missing: " + f. getAbsolutePath())
79+ }
80+
81+ File f2 = project. file(' ./resources/web/jbrowseApp/src/dijit/themes/dijit.css' );
82+ if (! f2. exists())
83+ {
84+ throw new GradleException (" copyJBrowse was not successful. missing jbrowse dependencies: " + f2. getAbsolutePath())
85+ }
86+
87+ // NOTE: due to bug/inconsistency in how the jbrowse postinstall script is run, several modules may not be copied to /src. This is a check against this.
88+ // There's a jbrowse PR around this as well.
89+ File f3 = project. file(' ./resources/web/jbrowseApp/src/jszlib' );
90+ if (! f3. exists())
91+ {
92+ throw new GradleException (" copyJBrowse was not successful. missing jbrowse dependencies: " + f3. getAbsolutePath())
93+ }
94+ })
95+
96+
97+ project. tasks. copyJBrowse. dependsOn(project. tasks. npmInstall)
98+
99+ project. tasks. copyJBrowse. mustRunAfter(" npmRunBuild" )
100+ project. tasks. copyJBrowse. mustRunAfter(" npmRunBuildProd" )
101+
102+ project. tasks. copyJBrowseCss. dependsOn(project. tasks. copyJBrowse)
103+ project. tasks. processModuleResources. dependsOn(project. tasks. copyJBrowse)
104+ project. tasks. processModuleResources. dependsOn(project. tasks. copyJBrowseCss)
0 commit comments