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
74265798
Commit
74265798
authored
Aug 23, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve the error message when additional build-info prop has null value
Closes gh-6724
parent
f41e6297
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
2 deletions
+32
-2
BuildPropertiesWriter.java
...ingframework/boot/loader/tools/BuildPropertiesWriter.java
+25
-0
BuildInfoMojo.java
...in/java/org/springframework/boot/maven/BuildInfoMojo.java
+7
-2
No files found.
spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/BuildPropertiesWriter.java
View file @
74265798
...
...
@@ -22,6 +22,7 @@ import java.io.IOException;
import
java.text.SimpleDateFormat
;
import
java.util.Date
;
import
java.util.Map
;
import
java.util.Map.Entry
;
import
java.util.Properties
;
/**
...
...
@@ -119,9 +120,21 @@ public final class BuildPropertiesWriter {
this
.
artifact
=
artifact
;
this
.
name
=
name
;
this
.
version
=
version
;
validateAdditionalProperties
(
additionalProperties
);
this
.
additionalProperties
=
additionalProperties
;
}
private
static
void
validateAdditionalProperties
(
Map
<
String
,
String
>
additionalProperties
)
{
if
(
additionalProperties
!=
null
)
{
for
(
Entry
<
String
,
String
>
property
:
additionalProperties
.
entrySet
())
{
if
(
property
.
getValue
()
==
null
)
{
throw
new
NullAdditionalPropertyValueException
(
property
.
getKey
());
}
}
}
}
public
String
getGroup
()
{
return
this
.
group
;
}
...
...
@@ -143,4 +156,16 @@ public final class BuildPropertiesWriter {
}
}
/**
* Exception thrown when an additional property with a null value is encountered.
*/
public
static
class
NullAdditionalPropertyValueException
extends
IllegalArgumentException
{
public
NullAdditionalPropertyValueException
(
String
name
)
{
super
(
"Additional property '"
+
name
+
"' is illegal as its value is null"
);
}
}
}
spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/BuildInfoMojo.java
View file @
74265798
...
...
@@ -28,6 +28,7 @@ import org.apache.maven.plugins.annotations.Parameter;
import
org.apache.maven.project.MavenProject
;
import
org.springframework.boot.loader.tools.BuildPropertiesWriter
;
import
org.springframework.boot.loader.tools.BuildPropertiesWriter.NullAdditionalPropertyValueException
;
import
org.springframework.boot.loader.tools.BuildPropertiesWriter.ProjectDetails
;
/**
...
...
@@ -53,8 +54,8 @@ public class BuildInfoMojo extends AbstractMojo {
private
File
outputFile
;
/**
* Additional properties to store in the build-info.properties. Each entry is prefixed
by
* {@code build.} in the generated build-info.properties.
* Additional properties to store in the build-info.properties. Each entry is prefixed
*
by
{@code build.} in the generated build-info.properties.
*/
@Parameter
private
Map
<
String
,
String
>
additionalProperties
;
...
...
@@ -67,6 +68,10 @@ public class BuildInfoMojo extends AbstractMojo {
this
.
project
.
getArtifactId
(),
this
.
project
.
getVersion
(),
this
.
project
.
getName
(),
this
.
additionalProperties
));
}
catch
(
NullAdditionalPropertyValueException
ex
)
{
throw
new
MojoFailureException
(
"Failed to generated build-info.properties. "
+
ex
.
getMessage
(),
ex
);
}
catch
(
Exception
ex
)
{
throw
new
MojoExecutionException
(
ex
.
getMessage
(),
ex
);
}
...
...
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