-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
229 lines (207 loc) · 11.3 KB
/
Copy pathbuild.gradle
File metadata and controls
229 lines (207 loc) · 11.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
plugins {
id 'java'
id 'org.springframework.boot' version '4.0.6'
id 'io.spring.dependency-management' version '1.1.7'
}
group = 'de.tum.cit.aet.artemis'
version = '0.1.0-SNAPSHOT'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(25)
}
}
repositories {
mavenCentral()
}
def nodeModulesDir = layout.projectDirectory.dir('node_modules')
def frontendOutputDir = layout.buildDirectory.dir('webapp/browser')
def frontendResourcesDir = layout.buildDirectory.dir('generated/frontendResources')
def skipFrontendBuild = providers.gradleProperty('skipFrontendBuild')
.map { it.isBlank() || it.toBoolean() }
.getOrElse(false)
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'com.github.javaparser:javaparser-core:3.26.4'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
def smokeTestArtemisPath = providers.gradleProperty('artemisPath')
if (smokeTestArtemisPath.isPresent()) {
systemProperty 'artemisPath', smokeTestArtemisPath.get()
}
}
// Single configuration boundary of the feature extraction commands. Every repository-relative input is declared here
// and passed explicitly to Java; the machine-specific Artemis checkout is never committed and is resolved from the
// -PartemisPath property first and the ARTEMIS_PATH environment variable second.
def featureExtraction = [
manifest : providers.gradleProperty('featureManifestPath')
.getOrElse(layout.projectDirectory.file('src/main/resources/feature-model/extraction/artemis-feature-manifest.yml').asFile.path),
manifestSource : providers.gradleProperty('featureManifestSource').getOrElse('repository'),
authoredWorkflow : layout.projectDirectory.file('src/main/resources/feature-model/guided-workflow.json').asFile.path,
deploymentProfile : layout.projectDirectory.file('src/main/resources/deployment-profiles/default-artemis-profile.json').asFile.path,
runtimeImage : layout.projectDirectory.file('delivery/artemis-runtime-image.json').asFile.path,
outputRoot : layout.buildDirectory.dir('feature-extraction').get().asFile.path,
artemisPath : providers.gradleProperty('artemisPath').orElse(providers.environmentVariable('ARTEMIS_PATH')),
expectedArtemisSha: providers.gradleProperty('expectedArtemisSha'),
]
// Every extraction command shares one main class and the same repository-relative options; each command derives its
// run identity from the checkout HEAD, and only the scan reads Artemis sources. None of them declares an up-to-date
// check: the scan depends on mutable checkout state and each later command must be able to observe an edited manifest
// or authored workflow.
def registerExtractionCommand = { String taskName, String command, String taskDescription ->
tasks.register(taskName, JavaExec) {
description = taskDescription
group = 'feature model'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'de.tum.cit.aet.artemis.featuremodel.extraction.FeatureExtractionCli'
outputs.upToDateWhen { false }
args = [command, "--manifest=${featureExtraction.manifest}", "--manifest-source=${featureExtraction.manifestSource}",
"--authored-workflow=${featureExtraction.authoredWorkflow}",
"--deployment-profile=${featureExtraction.deploymentProfile}", "--runtime-image=${featureExtraction.runtimeImage}",
"--output-root=${featureExtraction.outputRoot}"]
if (featureExtraction.artemisPath.isPresent()) {
// An absent checkout is not reported here: the command itself must run so that it fails with the
// actionable configuration message instead of a silent Gradle no-op.
args = args + ["--artemis-path=${featureExtraction.artemisPath.get()}"]
}
if (featureExtraction.expectedArtemisSha.isPresent()) {
args = args + ["--expected-artemis-sha=${featureExtraction.expectedArtemisSha.get()}"]
}
}
}
registerExtractionCommand('featureModelManifestPreflight', 'preflight',
'Validates the scope manifest and prints the derived Artemis source revision and the manifest digest.')
registerExtractionCommand('extractFeatureCandidates', 'scan',
'Scans the verified Artemis checkout and writes feature candidates, evidence, and relation candidates.')
registerExtractionCommand('assembleFeatureModel', 'model',
'Applies the scope manifest to an existing scan and assembles the generated feature model and catalog.')
registerExtractionCommand('prepareGuidedWorkflow', 'workflow',
'Validates the authored guided workflow against the generated model and prepares the build copy.')
registerExtractionCommand('packageFeatureModelSnapshot', 'snapshot',
'Consolidates the extraction report and publishes the importable feature model snapshot.')
tasks.named('assembleFeatureModel') { mustRunAfter tasks.named('extractFeatureCandidates') }
tasks.named('prepareGuidedWorkflow') { mustRunAfter tasks.named('assembleFeatureModel') }
tasks.named('packageFeatureModelSnapshot') { mustRunAfter tasks.named('prepareGuidedWorkflow') }
tasks.register('buildFeatureModelSnapshot') {
description = 'Runs the complete local extraction pipeline: scan, model assembly, workflow preparation, and snapshot packaging.'
group = 'feature model'
dependsOn tasks.named('extractFeatureCandidates'), tasks.named('assembleFeatureModel'), tasks.named('prepareGuidedWorkflow'),
tasks.named('packageFeatureModelSnapshot')
}
tasks.register('extractFeatureModel') {
description = 'Deprecated alias of buildFeatureModelSnapshot; use the staged commands or the aggregate task instead.'
group = 'feature model'
dependsOn tasks.named('buildFeatureModelSnapshot')
doLast {
logger.warn('extractFeatureModel is deprecated and will be removed; run buildFeatureModelSnapshot instead.')
}
}
tasks.register('validateFeatureModelSnapshot', JavaExec) {
description = 'Validates a complete generated feature model snapshot without copying or activating it.'
group = 'feature model'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'de.tum.cit.aet.artemis.featuremodel.extraction.FeatureModelSnapshotValidatorCli'
def snapshotPath = providers.gradleProperty('snapshotPath')
doFirst {
if (!snapshotPath.isPresent() || snapshotPath.get().isBlank()) {
throw new GradleException('Missing -PsnapshotPath=<snapshot-directory> for validateFeatureModelSnapshot.')
}
args = ["--snapshot-path=${snapshotPath.get()}"]
}
}
tasks.register('stageFeatureModelDockerContext', JavaExec) {
description = 'Validates and atomically stages one snapshot as a controlled Docker BuildKit named context.'
group = 'feature model'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'de.tum.cit.aet.artemis.featuremodel.extraction.FeatureModelDockerContextCli'
outputs.upToDateWhen { false }
def snapshotPath = providers.gradleProperty('snapshotPath')
def outputPath = layout.buildDirectory.dir('docker/feature-model-snapshot')
doFirst {
if (!snapshotPath.isPresent() || snapshotPath.get().isBlank()) {
throw new GradleException('Missing -PsnapshotPath=<snapshot-directory> for stageFeatureModelDockerContext.')
}
args = ["--snapshot-path=${snapshotPath.get()}", "--output-path=${outputPath.get().asFile.path}"]
}
}
tasks.register('syncGuidedWorkflowScaffold', JavaExec) {
description = 'Synchronizes the authored guided workflow scaffold with the manifest include set without touching prose.'
group = 'feature model'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'de.tum.cit.aet.artemis.featuremodel.extraction.GuidedWorkflowScaffoldRunner'
doFirst {
// The scaffold reads the manifest through the same two-mode strategy as the extraction commands: the in-repo
// file in 'repository' mode, the canonical checkout path in 'checkout' mode (requiring -PartemisPath).
def scaffoldManifest = featureExtraction.manifest
if (featureExtraction.manifestSource == 'checkout') {
if (!featureExtraction.artemisPath.isPresent()) {
throw new GradleException('featureManifestSource=checkout requires -PartemisPath=<checkout> for syncGuidedWorkflowScaffold.')
}
scaffoldManifest = "${featureExtraction.artemisPath.get()}/supportingFiles/feature-model/artemis-feature-manifest.yml"
}
args = [featureExtraction.authoredWorkflow, scaffoldManifest,
layout.buildDirectory.file('guided-workflow-scaffold-report.json').get().asFile.path]
}
}
tasks.register('refreshFeatureModelFixture', JavaExec) {
description = 'Validates a generated snapshot and copies its model and catalog over the classpath fixture with a provenance sidecar.'
group = 'feature model'
classpath = sourceSets.main.runtimeClasspath
mainClass = 'de.tum.cit.aet.artemis.featuremodel.extraction.FeatureModelFixtureRefreshCli'
outputs.upToDateWhen { false }
def snapshotPath = providers.gradleProperty('snapshotPath')
def resourceDir = layout.projectDirectory.dir('src/main/resources/feature-model')
doFirst {
if (!snapshotPath.isPresent() || snapshotPath.get().isBlank()) {
throw new GradleException('Missing -PsnapshotPath=<snapshot-directory> for refreshFeatureModelFixture.')
}
args = ["--snapshot-path=${snapshotPath.get()}", "--resource-dir=${resourceDir.asFile.path}"]
}
}
tasks.register('npmCi', Exec) {
description = 'Installs frontend dependencies from package-lock.json.'
group = 'frontend'
onlyIf { !skipFrontendBuild }
commandLine 'npm', 'ci'
inputs.files 'package.json', 'package-lock.json'
outputs.dir nodeModulesDir
}
tasks.register('buildFrontend', Exec) {
description = 'Builds the Angular frontend for production.'
group = 'frontend'
onlyIf { !skipFrontendBuild }
dependsOn tasks.named('npmCi')
commandLine 'npm', 'run', 'build:prod'
inputs.files 'package.json', 'package-lock.json', 'angular.json', 'tsconfig.json', 'tsconfig.app.json'
inputs.dir 'src/main/webapp'
outputs.dir frontendOutputDir
}
tasks.register('verifyFrontendBuildOutput') {
description = 'Verifies that the Angular production build output exists.'
group = 'frontend'
if (!skipFrontendBuild) {
dependsOn tasks.named('buildFrontend')
}
inputs.dir frontendOutputDir
doLast {
def indexFile = frontendOutputDir.get().file('index.html').asFile
if (!indexFile.exists()) {
throw new GradleException('Angular production build output is missing. Run npm run build:prod or remove -PskipFrontendBuild.')
}
}
}
tasks.register('copyFrontendResources', Copy) {
description = 'Copies Angular production assets into Spring Boot static resources for bootJar.'
group = 'frontend'
dependsOn tasks.named('verifyFrontendBuildOutput')
from frontendOutputDir
into frontendResourcesDir.map { it.dir('static') }
}
tasks.named('bootJar') {
dependsOn tasks.named('copyFrontendResources')
from(frontendResourcesDir) {
into 'BOOT-INF/classes'
}
}