mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-07-05 00:56:58 +08:00
Refine antora npx command
Build the nox args directly to ensure the correct `--package` is used. See gh-40132
This commit is contained in:
parent
5282d9878e
commit
70a4bc8023
73
buildSrc/.idea/workspace.xml
Normal file
73
buildSrc/.idea/workspace.xml
Normal file
@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="ec2b7321-da06-4cd3-94ad-6fffbdc49c98" name="Changes" comment="" />
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="ExternalProjectsData">
|
||||
<projectState path="$PROJECT_DIR$">
|
||||
<ProjectState />
|
||||
</projectState>
|
||||
</component>
|
||||
<component name="ExternalProjectsManager">
|
||||
<system id="GRADLE">
|
||||
<state>
|
||||
<projects_view>
|
||||
<tree_state>
|
||||
<expand />
|
||||
<select />
|
||||
</tree_state>
|
||||
</projects_view>
|
||||
</state>
|
||||
</system>
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/.." />
|
||||
</component>
|
||||
<component name="ProjectId" id="2djzqHE4bOA1VqmRcFFfIGFOV3M" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"last_opened_file_path": "/Users/pwebb/projects/spring-boot/code/3.3.x/buildSrc",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"project.structure.last.edited": "Project",
|
||||
"project.structure.proportion": "0.0",
|
||||
"project.structure.side.proportion": "0.2",
|
||||
"settings.editor.selected.configurable": "reference.projectsettings.compiler.javacompiler",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="ec2b7321-da06-4cd3-94ad-6fffbdc49c98" name="Changes" comment="" />
|
||||
<created>1710536464815</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1710536464815</updated>
|
||||
<workItem from="1710536465874" duration="2159000" />
|
||||
</task>
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
<select />
|
||||
</component>
|
||||
</project>
|
@ -19,6 +19,8 @@ package org.springframework.boot.build;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.UncheckedIOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@ -29,9 +31,9 @@ import com.github.gradle.node.NodeExtension;
|
||||
import com.github.gradle.node.npm.task.NpmInstallTask;
|
||||
import io.spring.gradle.antora.GenerateAntoraYmlPlugin;
|
||||
import io.spring.gradle.antora.GenerateAntoraYmlTask;
|
||||
import org.antora.gradle.AntoraExtension;
|
||||
import org.antora.gradle.AntoraPlugin;
|
||||
import org.antora.gradle.AntoraTask;
|
||||
import org.gradle.StartParameter;
|
||||
import org.gradle.api.Project;
|
||||
import org.gradle.api.logging.LogLevel;
|
||||
import org.gradle.api.plugins.JavaBasePlugin;
|
||||
@ -77,8 +79,6 @@ public class AntoraConventions {
|
||||
generateAntoraYmlTask, dependencyVersionsTask));
|
||||
tasks.withType(AntoraTask.class,
|
||||
(antoraTask) -> configureAntoraTask(project, antoraTask, npmInstallTask, generateAntoraPlaybookTask));
|
||||
project.getExtensions()
|
||||
.configure(AntoraExtension.class, (antoraExtension) -> configureAntoraExtension(project, antoraExtension));
|
||||
project.getExtensions()
|
||||
.configure(NodeExtension.class, (nodeExtension) -> configureNodeExtension(project, nodeExtension));
|
||||
}
|
||||
@ -101,7 +101,7 @@ public class AntoraConventions {
|
||||
environment.put("npm_config_omit", "optional");
|
||||
environment.put("npm_config_update_notifier", "false");
|
||||
npmInstallTask.getEnvironment().set(environment);
|
||||
npmInstallTask.getNpmCommand().set(List.of("ci"));
|
||||
npmInstallTask.getNpmCommand().set(List.of("ci", "--quiet"));
|
||||
}
|
||||
|
||||
private ExtractVersionConstraints addDependencyVersionsTask(Project project) {
|
||||
@ -152,6 +152,7 @@ public class AntoraConventions {
|
||||
antoraTask.dependsOn(npmInstallTask, generateAntoraPlaybookTask);
|
||||
antoraTask.setPlaybook("antora-playbook.yml");
|
||||
antoraTask.setUiBundleUrl(getUiBundleUrl(project));
|
||||
antoraTask.getArgs().set(project.provider(() -> getAntoraNpxArs(project, antoraTask)));
|
||||
project.getPlugins()
|
||||
.withType(JavaBasePlugin.class,
|
||||
(javaBasePlugin) -> project.getTasks()
|
||||
@ -159,6 +160,30 @@ public class AntoraConventions {
|
||||
.dependsOn(antoraTask));
|
||||
}
|
||||
|
||||
private List<String> getAntoraNpxArs(Project project, AntoraTask antoraTask) {
|
||||
logWarningIfNodeModulesInUserHome(project);
|
||||
StartParameter startParameter = project.getGradle().getStartParameter();
|
||||
boolean showStacktrace = startParameter.getShowStacktrace().name().startsWith("ALWAYS");
|
||||
boolean debugLogging = project.getGradle().getStartParameter().getLogLevel() == LogLevel.DEBUG;
|
||||
String playbookPath = antoraTask.getPlaybook();
|
||||
List<String> arguments = new ArrayList<>();
|
||||
arguments.addAll(List.of("--package", "@antora/cli"));
|
||||
arguments.add("antora");
|
||||
arguments.addAll((!showStacktrace) ? Collections.emptyList() : List.of("--stacktrace"));
|
||||
arguments.addAll((!debugLogging) ? List.of("--quiet") : List.of("--log-level", "all"));
|
||||
arguments.addAll(List.of("--ui-bundle-url", antoraTask.getUiBundleUrl()));
|
||||
arguments.add(playbookPath);
|
||||
return arguments;
|
||||
}
|
||||
|
||||
private void logWarningIfNodeModulesInUserHome(Project project) {
|
||||
if (new File(System.getProperty("user.home"), "node_modules").exists()) {
|
||||
project.getLogger()
|
||||
.warn("Detected the existence of $HOME/node_modules. This directory is "
|
||||
+ "not compatible with this plugin. Please remove it.");
|
||||
}
|
||||
}
|
||||
|
||||
private String getUiBundleUrl(Project project) {
|
||||
try {
|
||||
File packageJson = project.getRootProject().file("antora/package.json");
|
||||
@ -174,15 +199,6 @@ public class AntoraConventions {
|
||||
}
|
||||
}
|
||||
|
||||
private void configureAntoraExtension(Project project, AntoraExtension antoraExtension) {
|
||||
if (project.getGradle().getStartParameter().getLogLevel() != LogLevel.DEBUG) {
|
||||
antoraExtension.getOptions().add("--quiet");
|
||||
}
|
||||
else {
|
||||
antoraExtension.getOptions().addAll("--log-level", "all");
|
||||
}
|
||||
}
|
||||
|
||||
private void configureNodeExtension(Project project, NodeExtension nodeExtension) {
|
||||
File buildDir = project.getBuildDir();
|
||||
nodeExtension.getWorkDir().set(buildDir.toPath().resolve(".gradle/nodejs").toFile());
|
||||
|
Loading…
Reference in New Issue
Block a user