Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
5bd9a445
Commit
5bd9a445
authored
Jun 08, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
db7789ad
6f2171c2
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
7 deletions
+38
-7
MainClassConvention.java
...ringframework/boot/gradle/plugin/MainClassConvention.java
+4
-2
BootArchive.java
...ringframework/boot/gradle/tasks/bundling/BootArchive.java
+0
-1
BootJar.java
...g/springframework/boot/gradle/tasks/bundling/BootJar.java
+9
-2
BootWar.java
...g/springframework/boot/gradle/tasks/bundling/BootWar.java
+7
-0
JavaPluginActionIntegrationTests.java
.../boot/gradle/plugin/JavaPluginActionIntegrationTests.java
+9
-1
WarPluginActionIntegrationTests.java
...k/boot/gradle/plugin/WarPluginActionIntegrationTests.java
+9
-1
No files found.
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/MainClassConvention.java
View file @
5bd9a445
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
@@ -22,6 +22,7 @@ import java.util.Objects;
...
@@ -22,6 +22,7 @@ import java.util.Objects;
import
java.util.concurrent.Callable
;
import
java.util.concurrent.Callable
;
import
java.util.function.Supplier
;
import
java.util.function.Supplier
;
import
org.gradle.api.InvalidUserDataException
;
import
org.gradle.api.Project
;
import
org.gradle.api.Project
;
import
org.gradle.api.file.FileCollection
;
import
org.gradle.api.file.FileCollection
;
...
@@ -66,7 +67,8 @@ final class MainClassConvention implements Callable<Object> {
...
@@ -66,7 +67,8 @@ final class MainClassConvention implements Callable<Object> {
private
String
resolveMainClass
()
{
private
String
resolveMainClass
()
{
return
this
.
classpathSupplier
.
get
().
filter
(
File:
:
isDirectory
).
getFiles
().
stream
()
return
this
.
classpathSupplier
.
get
().
filter
(
File:
:
isDirectory
).
getFiles
().
stream
()
.
map
(
this
::
findMainClass
).
filter
(
Objects:
:
nonNull
).
findFirst
()
.
map
(
this
::
findMainClass
).
filter
(
Objects:
:
nonNull
).
findFirst
()
.
orElse
(
null
);
.
orElseThrow
(()
->
new
InvalidUserDataException
(
"Main class name has not been configured and it could not be resolved"
));
}
}
private
String
findMainClass
(
File
file
)
{
private
String
findMainClass
(
File
file
)
{
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootArchive.java
View file @
5bd9a445
...
@@ -39,7 +39,6 @@ public interface BootArchive extends Task {
...
@@ -39,7 +39,6 @@ public interface BootArchive extends Task {
* @return the main class name
* @return the main class name
*/
*/
@Input
@Input
@Optional
String
getMainClassName
();
String
getMainClassName
();
/**
/**
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java
View file @
5bd9a445
...
@@ -42,10 +42,10 @@ public class BootJar extends Jar implements BootArchive {
...
@@ -42,10 +42,10 @@ public class BootJar extends Jar implements BootArchive {
private
final
CopySpec
bootInf
;
private
final
CopySpec
bootInf
;
private
FileCollection
classpath
;
private
String
mainClassName
;
private
String
mainClassName
;
private
FileCollection
classpath
;
/**
/**
* Creates a new {@code BootJar} task.
* Creates a new {@code BootJar} task.
*/
*/
...
@@ -76,6 +76,13 @@ public class BootJar extends Jar implements BootArchive {
...
@@ -76,6 +76,13 @@ public class BootJar extends Jar implements BootArchive {
@Override
@Override
public
String
getMainClassName
()
{
public
String
getMainClassName
()
{
if
(
this
.
mainClassName
==
null
)
{
String
manifestStartClass
=
(
String
)
getManifest
().
getAttributes
()
.
get
(
"Start-Class"
);
if
(
manifestStartClass
!=
null
)
{
setMainClassName
(
manifestStartClass
);
}
}
return
this
.
mainClassName
;
return
this
.
mainClassName
;
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootWar.java
View file @
5bd9a445
...
@@ -68,6 +68,13 @@ public class BootWar extends War implements BootArchive {
...
@@ -68,6 +68,13 @@ public class BootWar extends War implements BootArchive {
@Override
@Override
public
String
getMainClassName
()
{
public
String
getMainClassName
()
{
if
(
this
.
mainClassName
==
null
)
{
String
manifestStartClass
=
(
String
)
getManifest
().
getAttributes
()
.
get
(
"Start-Class"
);
if
(
manifestStartClass
!=
null
)
{
setMainClassName
(
manifestStartClass
);
}
}
return
this
.
mainClassName
;
return
this
.
mainClassName
;
}
}
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/JavaPluginActionIntegrationTests.java
View file @
5bd9a445
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
@@ -104,6 +104,14 @@ public class JavaPluginActionIntegrationTests {
...
@@ -104,6 +104,14 @@ public class JavaPluginActionIntegrationTests {
assertThat
(
result
.
task
(
":jar"
).
getOutcome
()).
isEqualTo
(
TaskOutcome
.
SKIPPED
);
assertThat
(
result
.
task
(
":jar"
).
getOutcome
()).
isEqualTo
(
TaskOutcome
.
SKIPPED
);
}
}
@Test
public
void
errorMessageIsHelpfulWhenMainClassCannotBeResolved
()
{
BuildResult
result
=
this
.
gradleBuild
.
buildAndFail
(
"build"
,
"-PapplyJavaPlugin"
);
assertThat
(
result
.
task
(
":bootJar"
).
getOutcome
()).
isEqualTo
(
TaskOutcome
.
FAILED
);
assertThat
(
result
.
getOutput
()).
contains
(
"Main class name has not been configured and it could not be resolved"
);
}
@Test
@Test
public
void
jarAndBootJarCanBothBeBuilt
()
{
public
void
jarAndBootJarCanBothBeBuilt
()
{
BuildResult
result
=
this
.
gradleBuild
.
build
(
"assemble"
);
BuildResult
result
=
this
.
gradleBuild
.
build
(
"assemble"
);
...
...
spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/plugin/WarPluginActionIntegrationTests.java
View file @
5bd9a445
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
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.
...
@@ -72,4 +72,12 @@ public class WarPluginActionIntegrationTests {
...
@@ -72,4 +72,12 @@ public class WarPluginActionIntegrationTests {
this
.
gradleBuild
.
getProjectDir
().
getName
()
+
"-boot.war"
));
this
.
gradleBuild
.
getProjectDir
().
getName
()
+
"-boot.war"
));
}
}
@Test
public
void
errorMessageIsHelpfulWhenMainClassCannotBeResolved
()
{
BuildResult
result
=
this
.
gradleBuild
.
buildAndFail
(
"build"
,
"-PapplyWarPlugin"
);
assertThat
(
result
.
task
(
":bootWar"
).
getOutcome
()).
isEqualTo
(
TaskOutcome
.
FAILED
);
assertThat
(
result
.
getOutput
()).
contains
(
"Main class name has not been configured and it could not be resolved"
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment