Skip to content

Commit a2af7f4

Browse files
committed
add nx with dte
1 parent 1ae0548 commit a2af7f4

File tree

26 files changed

+2143
-19
lines changed

26 files changed

+2143
-19
lines changed

.env

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
NX_BATCH_MODE=true
2+
NX_VERBOSE_LOGGING=true
3+
NX_CLOUD_VERBOSE_LOGGING=true
4+
NX_TUI=false
5+
CI=true

.github/actions/build/action.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ runs:
6868
COMMERCIAL_REPO_PASSWORD: ${{ inputs.commercial-repository-password }}
6969
COMMERCIAL_REPO_USERNAME: ${{ inputs.commercial-repository-username }}
7070
COMMERCIAL_SNAPSHOT_REPO_URL: ${{ inputs.commercial-snapshot-repository-url }}
71-
run: ./gradlew build
72-
- name: Publish
73-
id: publish
74-
if: ${{ inputs.publish == 'true' }}
75-
shell: bash
76-
env:
77-
COMMERCIAL_RELEASE_REPO_URL: ${{ inputs.commercial-release-repository-url }}
78-
COMMERCIAL_REPO_PASSWORD: ${{ inputs.commercial-repository-password }}
79-
COMMERCIAL_REPO_USERNAME: ${{ inputs.commercial-repository-username }}
80-
COMMERCIAL_SNAPSHOT_REPO_URL: ${{ inputs.commercial-snapshot-repository-url }}
81-
run: ./gradlew -PdeploymentRepository=$(pwd)/deployment-repository ${{ !startsWith(github.event.head_commit.message, 'Next development version') && 'build' || '' }} publishAllPublicationsToDeploymentRepository
71+
run: NX_BATCH_MODE=true NX_CLOUD_DEREFERENCE_SYMLINKS=true NX_VERBOSE_LOGGING=true NX_PERF_LOGGING=true NX_CLOUD_NO_TIMEOUTS=true NX_CLOUD_VERBOSE_LOGGING=true npx nx run-many -t build-ci --parallel=32 --batch --outputStyle=stream
72+
# - name: Publish
73+
# id: publish
74+
# if: ${{ inputs.publish == 'true' }}
75+
# shell: bash
76+
# env:
77+
# COMMERCIAL_RELEASE_REPO_URL: ${{ inputs.commercial-release-repository-url }}
78+
# COMMERCIAL_REPO_PASSWORD: ${{ inputs.commercial-repository-password }}
79+
# COMMERCIAL_REPO_USERNAME: ${{ inputs.commercial-repository-username }}
80+
# COMMERCIAL_SNAPSHOT_REPO_URL: ${{ inputs.commercial-snapshot-repository-url }}
81+
# run: ./gradlew -PdeploymentRepository=$(pwd)/deployment-repository ${{ !startsWith(github.event.head_commit.message, 'Next development version') && 'build' || '' }} publishAllPublicationsToDeploymentRepository
8282
- name: Read Version From gradle.properties
8383
id: read-version
8484
shell: bash

.github/workflows/build-pull-request.yml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,30 @@ permissions:
55
jobs:
66
build:
77
name: Build Pull Request
8-
if: ${{ github.repository == 'spring-projects/spring-boot' }}
98
runs-on: ${{ vars.UBUNTU_MEDIUM || 'ubuntu-latest' }}
109
steps:
1110
- name: Check Out Code
1211
uses: actions/checkout@v4
12+
- name: Use Node.js
13+
uses: actions/setup-node@v4
14+
with:
15+
node-version: 22
16+
check-latest: true
17+
cache: npm
18+
- run: npm install
19+
20+
# This enables task distribution via Nx Cloud
21+
# Run this command as early as possible, before dependencies are installed
22+
# Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun
23+
# Uncomment this line to enable task distribution
24+
- run: NX_CLOUD_FORCE_USE_EXECUTE_TASKS_V3=false NX_CLOUD_DEREFERENCE_SYMLINKS=true NX_CLOUD_RETRIEVAL_CONCURRENCY=50 NX_CLOUD_NO_TIMEOUTS=true NX_VERBOSE_LOGGING=true NX_CLOUD_VERBOSE_LOGGING=true NX_PERF_LOGGING=true npx nx-cloud start-ci-run --require-explicit-completion --distribute-on="../../.nx/workflows/distribution-config.yaml"
25+
1326
- name: Build
1427
id: build
1528
uses: ./.github/actions/build
29+
- name: Stop nx cloud agents
30+
if: always()
31+
run: npx nx-cloud complete-ci-run
1632
- name: Print JVM Thread Dumps When Cancelled
1733
if: cancelled()
1834
uses: ./.github/actions/print-jvm-thread-dumps

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,10 @@ secrets.yml
4141
.sts4-cache
4242
.git-hooks/
4343
node_modules
44+
45+
.nx/installation
46+
.nx/cache
47+
.nx/workspace-data
48+
49+
.specstory/**
50+
.cursorindexingignore

.nx/nxw.js

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
"use strict";
2+
// This file should be committed to your repository! It wraps Nx and ensures
3+
// that your local installation matches nx.json.
4+
// See: https://nx.dev/recipes/installation/install-non-javascript for more info.
5+
6+
7+
8+
9+
Object.defineProperty(exports, "__esModule", { value: true });
10+
const fs = require('fs');
11+
const path = require('path');
12+
const cp = require('child_process');
13+
const installationPath = path.join(__dirname, 'installation', 'package.json');
14+
function matchesCurrentNxInstall(currentInstallation, nxJsonInstallation) {
15+
if (!currentInstallation.devDependencies ||
16+
!Object.keys(currentInstallation.devDependencies).length) {
17+
return false;
18+
}
19+
try {
20+
if (currentInstallation.devDependencies['nx'] !==
21+
nxJsonInstallation.version ||
22+
require(path.join(path.dirname(installationPath), 'node_modules', 'nx', 'package.json')).version !== nxJsonInstallation.version) {
23+
return false;
24+
}
25+
for (const [plugin, desiredVersion] of Object.entries(nxJsonInstallation.plugins || {})) {
26+
if (currentInstallation.devDependencies[plugin] !== desiredVersion) {
27+
return false;
28+
}
29+
}
30+
return true;
31+
}
32+
catch {
33+
return false;
34+
}
35+
}
36+
function ensureDir(p) {
37+
if (!fs.existsSync(p)) {
38+
fs.mkdirSync(p, { recursive: true });
39+
}
40+
}
41+
function getCurrentInstallation() {
42+
try {
43+
return require(installationPath);
44+
}
45+
catch {
46+
return {
47+
name: 'nx-installation',
48+
version: '0.0.0',
49+
devDependencies: {},
50+
};
51+
}
52+
}
53+
function performInstallation(currentInstallation, nxJson) {
54+
fs.writeFileSync(installationPath, JSON.stringify({
55+
name: 'nx-installation',
56+
devDependencies: {
57+
nx: nxJson.installation.version,
58+
...nxJson.installation.plugins,
59+
},
60+
}));
61+
try {
62+
cp.execSync('npm i', {
63+
cwd: path.dirname(installationPath),
64+
stdio: 'inherit',
65+
windowsHide: false,
66+
});
67+
}
68+
catch (e) {
69+
// revert possible changes to the current installation
70+
fs.writeFileSync(installationPath, JSON.stringify(currentInstallation));
71+
// rethrow
72+
throw e;
73+
}
74+
}
75+
function ensureUpToDateInstallation() {
76+
const nxJsonPath = path.join(__dirname, '..', 'nx.json');
77+
let nxJson;
78+
try {
79+
nxJson = require(nxJsonPath);
80+
if (!nxJson.installation) {
81+
console.error('[NX]: The "installation" entry in the "nx.json" file is required when running the nx wrapper. See https://nx.dev/recipes/installation/install-non-javascript');
82+
process.exit(1);
83+
}
84+
}
85+
catch {
86+
console.error('[NX]: The "nx.json" file is required when running the nx wrapper. See https://nx.dev/recipes/installation/install-non-javascript');
87+
process.exit(1);
88+
}
89+
try {
90+
ensureDir(path.join(__dirname, 'installation'));
91+
const currentInstallation = getCurrentInstallation();
92+
if (!matchesCurrentNxInstall(currentInstallation, nxJson.installation)) {
93+
performInstallation(currentInstallation, nxJson);
94+
}
95+
}
96+
catch (e) {
97+
const messageLines = [
98+
'[NX]: Nx wrapper failed to synchronize installation.',
99+
];
100+
if (e instanceof Error) {
101+
messageLines.push('');
102+
messageLines.push(e.message);
103+
messageLines.push(e.stack);
104+
}
105+
else {
106+
messageLines.push(e.toString());
107+
}
108+
console.error(messageLines.join('\n'));
109+
process.exit(1);
110+
}
111+
}
112+
if (!process.env.NX_WRAPPER_SKIP_INSTALL) {
113+
ensureUpToDateInstallation();
114+
}
115+
116+
require('./installation/node_modules/nx/bin/nx');

.nx/workflows/agents.yaml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
launch-templates:
2+
linux-extra-large-plus-jvm:
3+
env:
4+
NX_CLOUD_FORCE_USE_EXECUTE_TASKS_V3: "false"
5+
DOCKER_HOST: ""
6+
SERVICES_HOST: ""
7+
LANG: C.UTF-8
8+
resource-class: 'docker_linux_amd64/extra_large+'
9+
image: 'ubuntu22.04-node20.11-v10'
10+
init-steps:
11+
- name: java version
12+
script: java -version
13+
14+
- name: Checkout
15+
uses: 'nrwl/nx-cloud-workflows/v3.6/workflow-steps/checkout/main.yaml'
16+
17+
- name: Setup Java 21
18+
script: |
19+
sudo apt update
20+
sudo apt install -y openjdk-21-jdk
21+
sudo update-alternatives --set java /usr/lib/jvm/java-21-openjdk-amd64/bin/java
22+
java -version
23+
- name: Setup gradle
24+
script: ./gradlew wrapper && ./gradlew --stop && ./gradlew clean
25+
26+
- name: Restore Node Modules Cache
27+
uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
28+
inputs:
29+
key: 'package-lock.json|yarn.lock|pnpm-lock.yaml'
30+
paths: 'node_modules'
31+
base-branch: 'main'
32+
- name: Restore Browser Binary Cache
33+
uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/cache/main.yaml'
34+
inputs:
35+
key: 'package-lock.json|yarn.lock|pnpm-lock.yaml|"browsers"'
36+
paths: |
37+
'../.cache/Cypress'
38+
base-branch: 'main'
39+
- name: Install Node Modules
40+
uses: 'nrwl/nx-cloud-workflows/v4/workflow-steps/install-node-modules/main.yaml'
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
distribute-on:
2+
default: 5 linux-extra-large-plus-jvm
3+
4+
assignment-rules:
5+
- targets:
6+
- 'ciIntTest*'
7+
run-on:
8+
- agent: linux-extra-large-plus-jvm
9+
parallelism: 1
10+
11+
- projects:
12+
- "*"
13+
run-on:
14+
- agent: linux-extra-large-plus-jvm

build.gradle

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id "dev.nx.gradle.project-graph" version "0.1.2"
23
id "base"
34
id "org.jetbrains.kotlin.jvm" apply false // https://youtrack.jetbrains.com/issue/KT-30276
45
}
@@ -9,18 +10,21 @@ defaultTasks 'build'
910

1011
allprojects {
1112
group = "org.springframework.boot"
13+
apply {
14+
plugin("dev.nx.gradle.project-graph")
15+
}
1216
}
1317

1418
subprojects {
1519
apply plugin: "org.springframework.boot.conventions"
1620

1721
repositories {
22+
mavenLocal()
1823
mavenCentral()
1924
spring.mavenRepositories()
2025
}
2126

2227
configurations.all {
2328
resolutionStrategy.cacheChangingModulesFor 0, "minutes"
2429
}
25-
}
26-
30+
}

buildSrc/src/main/java/org/springframework/boot/build/AntoraConventions.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.gradle.api.plugins.JavaBasePlugin;
4343
import org.gradle.api.provider.Provider;
4444
import org.gradle.api.tasks.Copy;
45+
import org.gradle.api.tasks.PathSensitivity;
4546
import org.gradle.api.tasks.TaskContainer;
4647
import org.gradle.api.tasks.TaskProvider;
4748

@@ -90,7 +91,8 @@ private void apply(Project project, AntoraPlugin antoraPlugin) {
9091
TaskProvider<Copy> copyAntoraPackageJsonTask = tasks.register("copyAntoraPackageJson", Copy.class,
9192
(task) -> configureCopyAntoraPackageJsonTask(project, task));
9293
TaskProvider<NpmInstallTask> npmInstallTask = tasks.register("antoraNpmInstall", NpmInstallTask.class,
93-
(task) -> configureNpmInstallTask(project, task, copyAntoraPackageJsonTask));
94+
(task) -> configureNpmInstallTask(project, task, copyAntoraPackageJsonTask,
95+
generateAntoraPlaybookTask));
9496
tasks.withType(GenerateAntoraYmlTask.class,
9597
(generateAntoraYmlTask) -> configureGenerateAntoraYmlTask(project, generateAntoraYmlTask, resolvedBom));
9698
tasks.withType(AntoraTask.class,
@@ -114,13 +116,24 @@ private void configureCopyAntoraPackageJsonTask(Project project, Copy copyAntora
114116
}
115117

116118
private void configureNpmInstallTask(Project project, NpmInstallTask npmInstallTask,
117-
TaskProvider<Copy> copyAntoraPackageJson) {
119+
TaskProvider<Copy> copyAntoraPackageJson, TaskProvider<GenerateAntoraPlaybook> generateAntoraPlaybookTask) {
118120
npmInstallTask.dependsOn(copyAntoraPackageJson);
121+
npmInstallTask.dependsOn(generateAntoraPlaybookTask);
119122
Map<String, String> environment = new HashMap<>();
120123
environment.put("npm_config_omit", "optional");
121124
environment.put("npm_config_update_notifier", "false");
122125
npmInstallTask.getEnvironment().set(environment);
123126
npmInstallTask.getNpmCommand().set(List.of("ci", "--silent", "--no-progress"));
127+
128+
npmInstallTask.getInputs()
129+
.files(project.getLayout().getBuildDirectory().dir(".gradle/nodejs"))
130+
.withPropertyName("antoraNodeJs")
131+
.withPathSensitivity(PathSensitivity.RELATIVE);
132+
133+
npmInstallTask.getInputs()
134+
.files(getNodeProjectDir(project))
135+
.withPropertyName("antoraNodeProjectDir")
136+
.withPathSensitivity(PathSensitivity.RELATIVE);
124137
}
125138

126139
private void configureGenerateAntoraYmlTask(Project project, GenerateAntoraYmlTask generateAntoraYmlTask,
@@ -163,6 +176,22 @@ private void configureAntoraTask(Project project, AntoraTask antoraTask,
163176
TaskProvider<GenerateAntoraPlaybook> generateAntoraPlaybookTask) {
164177
antoraTask.setGroup("Documentation");
165178
antoraTask.dependsOn(npmInstallTask, generateAntoraPlaybookTask);
179+
180+
antoraTask.getInputs()
181+
.file(generateAntoraPlaybookTask.flatMap(GenerateAntoraPlaybook::getOutputFile))
182+
.withPropertyName("antoraPlaybookFile")
183+
.withPathSensitivity(PathSensitivity.RELATIVE);
184+
185+
antoraTask.getInputs()
186+
.files(project.getLayout().getBuildDirectory().dir(".gradle/nodejs"))
187+
.withPropertyName("antoraNodeJs")
188+
.withPathSensitivity(PathSensitivity.RELATIVE);
189+
190+
antoraTask.getInputs()
191+
.files(getNodeProjectDir(project))
192+
.withPropertyName("antoraNodeProjectDir")
193+
.withPathSensitivity(PathSensitivity.RELATIVE);
194+
166195
antoraTask.setPlaybook("antora-playbook.yml");
167196
antoraTask.setUiBundleUrl(getUiBundleUrl(project));
168197
antoraTask.getArgs().set(project.provider(() -> getAntoraNpxArs(project, antoraTask)));

buildSrc/src/main/java/org/springframework/boot/build/MavenRepositoryPlugin.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public void apply(Project project) {
7070
}
7171

7272
private void setUpProjectRepository(Project project, Task publishTask, File repositoryLocation) {
73+
publishTask.getOutputs().dir(repositoryLocation);
7374
publishTask.doFirst(new CleanAction(repositoryLocation));
7475
Configuration projectRepository = project.getConfigurations().create(MAVEN_REPOSITORY_CONFIGURATION_NAME);
7576
project.getArtifacts()

0 commit comments

Comments
 (0)