mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Use absolute path when showing classpath where main class was not found
Closes gh-40463
This commit is contained in:
parent
172b3d5336
commit
ca4d64ed16
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -174,7 +174,7 @@ final class JavaPluginAction implements PluginApplicationAction {
|
|||||||
.provider(() -> (String) bootJar.getManifest().getAttributes().get("Start-Class"));
|
.provider(() -> (String) bootJar.getManifest().getAttributes().get("Start-Class"));
|
||||||
bootJar.getMainClass()
|
bootJar.getMainClass()
|
||||||
.convention(resolveMainClassName.flatMap((resolver) -> manifestStartClass.isPresent()
|
.convention(resolveMainClassName.flatMap((resolver) -> manifestStartClass.isPresent()
|
||||||
? manifestStartClass : resolveMainClassName.get().readMainClassName()));
|
? manifestStartClass : resolver.readMainClassName()));
|
||||||
bootJar.getTargetJavaVersion()
|
bootJar.getTargetJavaVersion()
|
||||||
.set(project.provider(() -> javaPluginExtension(project).getTargetCompatibility()));
|
.set(project.provider(() -> javaPluginExtension(project).getTargetCompatibility()));
|
||||||
bootJar.resolvedArtifacts(runtimeClasspath.getIncoming().getArtifacts().getResolvedArtifacts());
|
bootJar.resolvedArtifacts(runtimeClasspath.getIncoming().getArtifacts().getResolvedArtifacts());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -153,9 +153,8 @@ public class ResolveMainClassName extends DefaultTask {
|
|||||||
String classpath = getClasspath().filter(File::isDirectory)
|
String classpath = getClasspath().filter(File::isDirectory)
|
||||||
.getFiles()
|
.getFiles()
|
||||||
.stream()
|
.stream()
|
||||||
.map((directory) -> getProject().getProjectDir().toPath().relativize(directory.toPath()))
|
.map(File::getAbsolutePath)
|
||||||
.map(Path::toString)
|
.collect(Collectors.joining(File.pathSeparator));
|
||||||
.collect(Collectors.joining(","));
|
|
||||||
return this.outputFile.map(new ClassNameReader(classpath));
|
return this.outputFile.map(new ClassNameReader(classpath));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -96,7 +96,7 @@ class WarPluginAction implements PluginApplicationAction {
|
|||||||
.provider(() -> (String) bootWar.getManifest().getAttributes().get("Start-Class"));
|
.provider(() -> (String) bootWar.getManifest().getAttributes().get("Start-Class"));
|
||||||
bootWar.getMainClass()
|
bootWar.getMainClass()
|
||||||
.convention(resolveMainClassName.flatMap((resolver) -> manifestStartClass.isPresent()
|
.convention(resolveMainClassName.flatMap((resolver) -> manifestStartClass.isPresent()
|
||||||
? manifestStartClass : resolveMainClassName.get().readMainClassName()));
|
? manifestStartClass : resolver.readMainClassName()));
|
||||||
bootWar.getTargetJavaVersion()
|
bootWar.getTargetJavaVersion()
|
||||||
.set(project.provider(() -> javaPluginExtension(project).getTargetCompatibility()));
|
.set(project.provider(() -> javaPluginExtension(project).getTargetCompatibility()));
|
||||||
bootWar.resolvedArtifacts(runtimeClasspath.getIncoming().getArtifacts().getResolvedArtifacts());
|
bootWar.resolvedArtifacts(runtimeClasspath.getIncoming().getArtifacts().getResolvedArtifacts());
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2012-2023 the original author or authors.
|
* Copyright 2012-2024 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@ -113,7 +113,7 @@ class BootTestRunIntegrationTests {
|
|||||||
else {
|
else {
|
||||||
assertThat(result.getOutput())
|
assertThat(result.getOutput())
|
||||||
.contains("Main class name has not been configured and it could not be resolved from classpath "
|
.contains("Main class name has not been configured and it could not be resolved from classpath "
|
||||||
+ String.join(File.separator, "build", "classes", "java", "test"));
|
+ canonicalPathOf("build/classes/java/test"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user