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
e4aab1cf
Commit
e4aab1cf
authored
Apr 09, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2736 from Nowheresly/fix747
* fix747: Support ANSI color from gradle bootRun
parents
ba2ea301
d8308cbf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
5 deletions
+28
-5
BootRunTask.java
...oovy/org/springframework/boot/gradle/run/BootRunTask.java
+4
-0
AnsiOutput.java
...c/main/java/org/springframework/boot/ansi/AnsiOutput.java
+16
-2
AnsiOutputApplicationListener.java
...rk/boot/context/config/AnsiOutputApplicationListener.java
+6
-1
AnsiOutputApplicationListenerTests.java
...t/embedded/config/AnsiOutputApplicationListenerTests.java
+2
-2
No files found.
spring-boot-tools/spring-boot-gradle-plugin/src/main/groovy/org/springframework/boot/gradle/run/BootRunTask.java
View file @
e4aab1cf
...
@@ -54,6 +54,10 @@ public class BootRunTask extends JavaExec {
...
@@ -54,6 +54,10 @@ public class BootRunTask extends JavaExec {
@Override
@Override
public
void
exec
()
{
public
void
exec
()
{
if
(
System
.
console
()
!=
null
)
{
// Record that the console is available here for AnsiOutput to detect later
this
.
getEnvironment
().
put
(
"spring.output.ansi.console-available"
,
true
);
}
addResourcesIfNecessary
();
addResourcesIfNecessary
();
super
.
exec
();
super
.
exec
();
}
}
...
...
spring-boot/src/main/java/org/springframework/boot/ansi/AnsiOutput.java
View file @
e4aab1cf
/*
/*
* Copyright 2012-201
3
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -30,6 +30,8 @@ public abstract class AnsiOutput {
...
@@ -30,6 +30,8 @@ public abstract class AnsiOutput {
private
static
Enabled
enabled
=
Enabled
.
DETECT
;
private
static
Enabled
enabled
=
Enabled
.
DETECT
;
private
static
Boolean
consoleAvailable
;
private
static
final
String
OPERATING_SYSTEM_NAME
=
System
.
getProperty
(
"os.name"
)
private
static
final
String
OPERATING_SYSTEM_NAME
=
System
.
getProperty
(
"os.name"
)
.
toLowerCase
();
.
toLowerCase
();
...
@@ -48,6 +50,15 @@ public abstract class AnsiOutput {
...
@@ -48,6 +50,15 @@ public abstract class AnsiOutput {
AnsiOutput
.
enabled
=
enabled
;
AnsiOutput
.
enabled
=
enabled
;
}
}
/**
* Sets if the System.console() is know to be available.
* @param consoleAvailable if the console is known to be available or {@code null} to
* use standard detection logic.
*/
public
static
void
setConsoleAvailable
(
Boolean
consoleAvailable
)
{
AnsiOutput
.
consoleAvailable
=
consoleAvailable
;
}
static
Enabled
getEnabled
()
{
static
Enabled
getEnabled
()
{
return
AnsiOutput
.
enabled
;
return
AnsiOutput
.
enabled
;
}
}
...
@@ -115,7 +126,10 @@ public abstract class AnsiOutput {
...
@@ -115,7 +126,10 @@ public abstract class AnsiOutput {
private
static
boolean
detectIfEnabled
()
{
private
static
boolean
detectIfEnabled
()
{
try
{
try
{
if
(
System
.
console
()
==
null
)
{
if
(
Boolean
.
FALSE
.
equals
(
consoleAvailable
))
{
return
false
;
}
if
((
consoleAvailable
==
null
)
&&
(
System
.
console
()
==
null
))
{
return
false
;
return
false
;
}
}
return
!(
OPERATING_SYSTEM_NAME
.
indexOf
(
"win"
)
>=
0
);
return
!(
OPERATING_SYSTEM_NAME
.
indexOf
(
"win"
)
>=
0
);
...
...
spring-boot/src/main/java/org/springframework/boot/context/config/AnsiOutputApplicationListener.java
View file @
e4aab1cf
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -42,6 +42,11 @@ public class AnsiOutputApplicationListener implements
...
@@ -42,6 +42,11 @@ public class AnsiOutputApplicationListener implements
String
enabled
=
resolver
.
getProperty
(
"enabled"
);
String
enabled
=
resolver
.
getProperty
(
"enabled"
);
AnsiOutput
.
setEnabled
(
Enum
.
valueOf
(
Enabled
.
class
,
enabled
.
toUpperCase
()));
AnsiOutput
.
setEnabled
(
Enum
.
valueOf
(
Enabled
.
class
,
enabled
.
toUpperCase
()));
}
}
if
(
resolver
.
containsProperty
(
"console-available"
))
{
AnsiOutput
.
setConsoleAvailable
(
resolver
.
getProperty
(
"console-available"
,
Boolean
.
class
));
}
}
}
@Override
@Override
...
...
spring-boot/src/test/java/org/springframework/boot/context/embedded/config/AnsiOutputApplicationListenerTests.java
View file @
e4aab1cf
/*
/*
* Copyright 2012-201
4
the original author or authors.
* Copyright 2012-201
5
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.
...
@@ -71,7 +71,7 @@ public class AnsiOutputApplicationListenerTests {
...
@@ -71,7 +71,7 @@ public class AnsiOutputApplicationListenerTests {
}
}
@Test
@Test
public
void
disabledViaApplcationProperties
()
throws
Exception
{
public
void
disabledViaAppl
i
cationProperties
()
throws
Exception
{
ConfigurableEnvironment
environment
=
new
StandardEnvironment
();
ConfigurableEnvironment
environment
=
new
StandardEnvironment
();
EnvironmentTestUtils
.
addEnvironment
(
environment
,
"spring.config.name:ansi"
);
EnvironmentTestUtils
.
addEnvironment
(
environment
,
"spring.config.name:ansi"
);
SpringApplication
application
=
new
SpringApplication
(
Config
.
class
);
SpringApplication
application
=
new
SpringApplication
(
Config
.
class
);
...
...
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