| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  | plugins { | 
					
						
							|  |  |  |   id 'java' | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  | apply plugin: 'distribution' | 
					
						
							|  |  |  | apply plugin: 'com.github.node-gradle.node' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | node { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // If true, it will download node using above parameters.
 | 
					
						
							|  |  |  |   // If false, it will try to use globally installed node.
 | 
					
						
							| 
									
										
										
										
											2021-11-09 20:50:06 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-09-02 16:02:46 +02:00
										 |  |  |   if (project.hasProperty('useSystemNode')) { | 
					
						
							|  |  |  |     download = ! project.getProperty('useSystemNode').toBoolean() | 
					
						
							| 
									
										
										
										
											2021-11-09 20:50:06 +01:00
										 |  |  |   } else { | 
					
						
							| 
									
										
										
										
											2023-01-31 18:44:37 -06:00
										 |  |  |     download = true | 
					
						
							| 
									
										
										
										
											2021-11-09 20:50:06 +01:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Version of node to use.
 | 
					
						
							| 
									
										
										
										
											2021-11-09 20:50:06 +01:00
										 |  |  |   version = '16.8.0' | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Version of Yarn to use.
 | 
					
						
							|  |  |  |   yarnVersion = '1.22.0' | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-03-31 16:15:25 +01:00
										 |  |  |   // Base URL for fetching node distributions (set nodeDistBaseUrl if you have a mirror).
 | 
					
						
							|  |  |  |   if (project.hasProperty('nodeDistBaseUrl')) { | 
					
						
							|  |  |  |     distBaseUrl = project.getProperty('nodeDistBaseUrl') | 
					
						
							|  |  |  |   } else { | 
					
						
							|  |  |  |     distBaseUrl = 'https://nodejs.org/dist' | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Set the work directory for unpacking node
 | 
					
						
							|  |  |  |   workDir = file("${project.projectDir}/.gradle/nodejs") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Set the work directory for NPM
 | 
					
						
							|  |  |  |   yarnWorkDir = file("${project.projectDir}/.gradle/yarn") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Set the work directory where node_modules should be located
 | 
					
						
							|  |  |  |   nodeModulesDir = file("${project.projectDir}") | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |   Wrappers around Yarn Tasks. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | task yarnInstall(type: YarnTask) { | 
					
						
							|  |  |  |   args = ['install'] | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task yarnGenerate(type: YarnTask, dependsOn: yarnInstall) { | 
					
						
							|  |  |  |   args = ['run', 'generate'] | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task yarnServe(type: YarnTask, dependsOn: [yarnInstall, yarnGenerate]) { | 
					
						
							|  |  |  |   args = ['run', 'start',  '--proxy', 'http://localhost:9001'] | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task yarnTest(type: YarnTask, dependsOn: [yarnInstall, yarnGenerate]) { | 
					
						
							|  |  |  |   args = ['run', 'test', '--watchAll', 'false'] | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-02-05 12:56:07 -08:00
										 |  |  | task yarnLint(type: YarnTask, dependsOn: [yarnInstall, yarnGenerate]) { | 
					
						
							|  |  |  |   args = ['run', 'lint'] | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  | test.dependsOn([yarnInstall, yarnTest, yarnLint]) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-02-07 22:52:59 +05:30
										 |  |  | task yarnLintFix(type: YarnTask, dependsOn: [yarnInstall, yarnGenerate]) { | 
					
						
							|  |  |  |   args = ['run', 'lint-fix'] | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-23 13:55:14 -07:00
										 |  |  | task yarnBuild(type: YarnTask, dependsOn: [yarnInstall, yarnTest, yarnLint]) { | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  |   args = ['run', 'build'] | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  | task yarnQuickBuild(type: YarnTask, dependsOn: [yarnInstall, yarnGenerate]) { | 
					
						
							| 
									
										
										
										
											2023-04-17 17:29:45 -05:00
										 |  |  |   environment = [NODE_OPTIONS: "--max-old-space-size=3072"] | 
					
						
							| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  |   args = ['run', 'build'] | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task cleanExtraDirs { | 
					
						
							| 
									
										
										
										
											2022-12-29 11:26:42 -06:00
										 |  |  |   delete 'node_modules/.yarn-integrity' | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  |   delete 'dist' | 
					
						
							|  |  |  |   delete 'tmp' | 
					
						
							|  |  |  |   delete 'just' | 
					
						
							| 
									
										
										
										
											2022-02-02 00:30:05 +05:30
										 |  |  |   delete 'src/types.generated.ts' | 
					
						
							| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  |   delete fileTree('../datahub-frontend/public') | 
					
						
							| 
									
										
										
										
											2022-07-15 06:08:32 -04:00
										 |  |  |   delete fileTree(dir: 'src/graphql', include: '*.generated.ts') | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  | clean.finalizedBy(cleanExtraDirs) | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | configurations { | 
					
						
							|  |  |  |   assets | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | distZip { | 
					
						
							| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  |   dependsOn yarnQuickBuild | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  |   baseName 'datahub-web-react' | 
					
						
							|  |  |  |   from 'dist' | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  | task copyAssets(dependsOn: distZip) { | 
					
						
							|  |  |  |   doLast { | 
					
						
							|  |  |  |     copy { | 
					
						
							|  |  |  |       from zipTree(distZip.outputs.files.first()) | 
					
						
							|  |  |  |       into "../datahub-frontend/public" | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-05-10 18:15:53 -05:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  | jar { | 
					
						
							|  |  |  |   dependsOn distZip, copyAssets | 
					
						
							|  |  |  |   into('public') { | 
					
						
							|  |  |  |     from zipTree(distZip.outputs.files.first()) | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  |   classifier = 'assets' | 
					
						
							| 
									
										
										
										
											2021-02-05 12:56:07 -08:00
										 |  |  | } |