@@ -2,13 +2,29 @@ buildscript {
22 repositories {
33 mavenCentral()
44 gradlePluginPortal()
5+ maven {
6+ url " https://plugins.gradle.org/m2/"
7+ }
58 }
69 dependencies {
710 classpath ' org.xtext:xtext-gradle-plugin:4.0.0'
11+ classpath ' com.github.node-gradle:gradle-node-plugin:3.3.0'
12+ classpath ' net.researchgate:gradle-release:2.8.1'
813 }
914}
1015
11- subprojects {
16+ apply plugin : ' com.github.node-gradle.node'
17+ apply plugin : ' net.researchgate.release'
18+ node {
19+ version = ' 16.13.2'
20+ npmVersion = ' 8.3.0'
21+ download = true
22+ }
23+
24+ tasks. named(" npmInstall" ). configure { enabled = false }
25+
26+ // Configuration for Xtext projects
27+ configure(subprojects. findAll { it. name. startsWith(' com.minres' ) }) {
1228 ext. xtextVersion = ' 2.33.0'
1329 repositories {
1430 mavenCentral()
@@ -22,16 +38,116 @@ subprojects {
2238 apply plugin : ' org.xtext.xtend'
2339 apply from : " ${ rootDir} /gradle/source-layout.gradle"
2440 apply plugin : ' eclipse'
25-
41+
2642 group = ' com.minres.coredsl'
27- version = ' 2.0.12-SNAPSHOT '
43+ version = ' 2.0.12'
2844
2945 java {
3046 sourceCompatibility = JavaVersion . VERSION_17
3147 targetCompatibility = JavaVersion . VERSION_17
3248 }
33-
49+
3450 configurations. all {
3551 exclude group : ' asm'
3652 }
53+
54+ }
55+
56+ task npmInstallVsce (type : NpmTask , dependsOn : npmSetup) {
57+ ext. destPath = " $rootProject . projectDir /node_modules/vsce"
58+ outputs. dir(destPath)
59+ group ' Node'
60+ description ' Installs the NodeJS package "Visual Studio Code Extension Manager"'
61+ args = [ ' install' , ' vsce' ]
62+ }
63+
64+ // Configuration for vscode projects
65+ configure(subprojects. findAll { it. name. startsWith(' vscode' ) }) {
66+
67+ apply plugin : ' com.github.node-gradle.node'
68+ node {
69+ version = ' 16.13.2'
70+ npmVersion = ' 8.3.0'
71+ download = true
72+ }
73+
74+ version = ' 2.0.12'
75+
76+ def inputFiles = fileTree(
77+ dir : projectDir,
78+ excludes : [ ' out/**' , ' .gitignore' , ' .gradle/**' , ' build/**' , ' *.gradle' ]
79+ )
80+
81+ npmInstall {
82+ inputs. files(inputFiles)
83+ outputs. dir(' out' )
84+ }
85+
86+ task vscodeExtension(dependsOn : [npmInstall, npmInstallVsce], type : NodeTask ) {
87+ ext. destDir = new File (buildDir, ' vscode' )
88+ ext. archiveName = " coredsl-vscode-${ project.version} .vsix"
89+ ext. destPath = " $destDir /$archiveName "
90+ inputs. with {
91+ files inputFiles
92+ dir npmInstallVsce. destPath
93+ }
94+ outputs. dir destDir
95+ doFirst {
96+ destDir. mkdirs()
97+ }
98+ script = file(" $npmInstallVsce . destPath /vsce" )
99+ args = [ ' package' , ' --out' , destPath ]
100+ execOverrides {
101+ workingDir = projectDir
102+ }
103+ }
104+
105+ task clean {
106+ doLast {
107+ delete vscodeExtension. destDir
108+ delete ' out' // output of npmInstall - don't want to delete node_modules
109+ }
110+
111+ }
112+
113+ }
114+
115+ plugins. withType(com.github.gradle.node.NodePlugin ) {
116+ node {
117+ workDir = file(" $rootProject . buildDir /nodejs" )
118+ nodeModulesDir = rootProject. projectDir
119+ }
120+ }
121+
122+ updateVersion {
123+ doLast {
124+ // custom code
125+ def versionPattern = / \d +.\d +(.\d +)?/
126+ def encoding = ' UTF-8'
127+ def filesToUpdate = [
128+ new File (' vscode-extension' , ' package.json' ),
129+ new File (' vscode-extension-self-contained' , ' package.json' ),
130+ ]
131+
132+ // String replacements - isn't long enough to justify advanced code ;)
133+ filesToUpdate. forEach { file ->
134+
135+ String text = file. getText(encoding)
136+ text = text. replaceAll(" \" version\" : \" $versionPattern \" ," , " \" version\" : \" $project . version \" ," )
137+ file. setText(text, encoding)
138+ }
139+ }
140+ }
141+
142+ release {
143+ tagTemplate = ' v${version}'
144+ preTagCommitMessage = ' [release] pre tag commit: '
145+ tagCommitMessage = ' [release] creating tag: '
146+ newVersionCommitMessage = ' [release] new version commit: '
147+ failOnSnapshotDependencies = false
148+ }
149+
150+ // Workaround for issue https://github.com/researchgate/gradle-release/issues/144
151+ task build {
152+ dependsOn subprojects. findResults { it. tasks. findByName(' build' ) }
37153}
0 commit comments