| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  | plugins { | 
					
						
							|  |  |  |   id 'java' | 
					
						
							| 
									
										
										
										
											2023-12-15 13:28:33 -06:00
										 |  |  |   id 'distribution' | 
					
						
							|  |  |  |   id 'com.github.node-gradle.node' | 
					
						
							| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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.
 | 
					
						
							| 
									
										
										
										
											2023-11-16 12:09:28 -06:00
										 |  |  |   version = '21.2.0' | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // Version of Yarn to use.
 | 
					
						
							| 
									
										
										
										
											2024-09-23 19:29:50 -05:00
										 |  |  |   yarnVersion = '1.22.22' | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											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
 | 
					
						
							| 
									
										
										
										
											2023-12-15 13:28:33 -06:00
										 |  |  |   nodeProjectDir = file("${project.projectDir}") | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* | 
					
						
							|  |  |  |   Wrappers around Yarn Tasks. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | task yarnInstall(type: YarnTask) { | 
					
						
							| 
									
										
										
										
											2024-09-23 19:29:50 -05:00
										 |  |  |   args = ['install', '--network-timeout', '300000'] | 
					
						
							| 
									
										
										
										
											2024-01-03 17:16:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // The node_modules directory can contain built artifacts, so
 | 
					
						
							|  |  |  |   // it's not really safe to cache it.
 | 
					
						
							|  |  |  |   outputs.cacheIf { false } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   inputs.files( | 
					
						
							|  |  |  |     file('yarn.lock'), | 
					
						
							|  |  |  |     file('package.json'), | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  |   outputs.dir('node_modules') | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task yarnGenerate(type: YarnTask, dependsOn: yarnInstall) { | 
					
						
							|  |  |  |   args = ['run', 'generate'] | 
					
						
							| 
									
										
										
										
											2024-01-03 17:16:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   outputs.cacheIf { true } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   inputs.files( | 
					
						
							|  |  |  |     yarnInstall.inputs.files, | 
					
						
							|  |  |  |     file('codegen.yml'), | 
					
						
							|  |  |  |     project.fileTree(dir: "../datahub-graphql-core/src/main/resources/", include: "*.graphql"), | 
					
						
							|  |  |  |     project.fileTree(dir: "src", include: "**/*.graphql"), | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   outputs.files( | 
					
						
							|  |  |  |     project.fileTree(dir: "src", include: "**/*.generated.ts"), | 
					
						
							|  |  |  |   ) | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task yarnServe(type: YarnTask, dependsOn: [yarnInstall, yarnGenerate]) { | 
					
						
							|  |  |  |   args = ['run', 'start',  '--proxy', 'http://localhost:9001'] | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | task yarnTest(type: YarnTask, dependsOn: [yarnInstall, yarnGenerate]) { | 
					
						
							| 
									
										
										
										
											2024-01-03 17:16:16 -05:00
										 |  |  |   // Explicitly runs in non-watch mode.
 | 
					
						
							|  |  |  |   args = ['run', 'test', 'run'] | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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'] | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-03 17:16:16 -05:00
										 |  |  | task yarnBuild(type: YarnTask, dependsOn: [yarnInstall, yarnGenerate]) { | 
					
						
							| 
									
										
										
										
											2023-11-21 16:23:21 -06:00
										 |  |  |   environment = [NODE_OPTIONS: "--max-old-space-size=3072 --openssl-legacy-provider"] | 
					
						
							| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  |   args = ['run', 'build'] | 
					
						
							| 
									
										
										
										
											2024-01-03 17:16:16 -05:00
										 |  |  | 
 | 
					
						
							|  |  |  |   outputs.cacheIf { true } | 
					
						
							|  |  |  |   inputs.files( | 
					
						
							|  |  |  |     file('index.html'), | 
					
						
							|  |  |  |     project.fileTree(dir: "src"), | 
					
						
							|  |  |  |     project.fileTree(dir: "public"), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     yarnInstall.inputs.files, | 
					
						
							|  |  |  |     yarnGenerate.outputs.files, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     file('.env'), | 
					
						
							|  |  |  |     file('vite.config.ts'), | 
					
						
							|  |  |  |     file('tsconfig.json'), | 
					
						
							|  |  |  |   ) | 
					
						
							|  |  |  |   outputs.dir('dist') | 
					
						
							| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 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' | 
					
						
							| 
									
										
										
										
											2024-04-16 04:49:21 +05:30
										 |  |  |   delete fileTree(dir: 'src', 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 { | 
					
						
							| 
									
										
										
										
											2024-01-03 17:16:16 -05:00
										 |  |  |   dependsOn yarnBuild | 
					
						
							| 
									
										
										
										
											2023-12-15 13:28:33 -06:00
										 |  |  |   archiveFileName = "datahub-web-react-${archiveVersion}.${archiveExtension}" | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  |   from 'dist' | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  | jar { | 
					
						
							| 
									
										
										
										
											2024-01-03 17:16:16 -05:00
										 |  |  |   dependsOn distZip | 
					
						
							| 
									
										
										
										
											2022-12-26 10:09:08 -06:00
										 |  |  |   into('public') { | 
					
						
							|  |  |  |     from zipTree(distZip.outputs.files.first()) | 
					
						
							| 
									
										
										
										
											2021-01-17 12:54:49 -08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-12-15 13:28:33 -06:00
										 |  |  |   archiveClassifier = 'assets' | 
					
						
							| 
									
										
										
										
											2021-02-05 12:56:07 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2024-01-03 17:16:16 -05:00
										 |  |  | build.dependsOn jar |