Skip to content

Commit 9722a4f

Browse files
authored
Fixes #27 : color logging is based on maven configuration (#31)
-B (batchmode) and -l <filename> (output to file) removes coloration -Dstyle.color=never removes coloration Note: style.color seems to require at least maven 3.5.3
1 parent b13cd2a commit 9722a4f

File tree

2 files changed

+6
-42
lines changed

2 files changed

+6
-42
lines changed

utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/UtPLSQLMojo.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import org.apache.maven.plugins.annotations.Mojo;
1717
import org.apache.maven.plugins.annotations.Parameter;
1818
import org.apache.maven.project.MavenProject;
19+
import org.apache.maven.shared.utils.logging.MessageUtils;
1920
import org.utplsql.api.DBHelper;
2021
import org.utplsql.api.FileMapperOptions;
2122
import org.utplsql.api.JavaApiVersionInfo;
@@ -61,14 +62,14 @@ public class UtPLSQLMojo extends AbstractMojo {
6162
protected boolean skipCompatibilityCheck;
6263

6364
@Parameter
64-
protected List<ReporterParameter> reporters = new ArrayList<ReporterParameter>();
65+
protected List<ReporterParameter> reporters = new ArrayList<>();
6566

6667
@Parameter
67-
protected List<String> paths = new ArrayList<String>();
68+
protected List<String> paths = new ArrayList<>();
6869

6970
// Sources Configuration
7071
@Parameter
71-
protected List<Resource> sources = new ArrayList<Resource>();
72+
protected List<Resource> sources = new ArrayList<>();
7273

7374
@Parameter
7475
private String sourcesOwner;
@@ -117,8 +118,8 @@ public class UtPLSQLMojo extends AbstractMojo {
117118
@Parameter(defaultValue = "${maven.test.failure.ignore}")
118119
protected boolean ignoreFailure;
119120

120-
// Color in the console, loaded by environment variables
121-
private boolean colorConsole = PluginDefault.resolveColor();
121+
// Color in the console, bases on maven logging configuration
122+
private boolean colorConsole = MessageUtils.isColorEnabled();
122123

123124
// Reporter Writer
124125
private ReporterWriter reporterWriter;

utplsql-maven-plugin/src/main/java/org/utplsql/maven/plugin/helper/PluginDefault.java

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package org.utplsql.maven.plugin.helper;
22

3-
import java.io.File;
43
import java.util.Arrays;
5-
import java.util.Map;
64

75
import org.apache.maven.model.Resource;
86

@@ -14,13 +12,6 @@
1412
*/
1513
public class PluginDefault
1614
{
17-
18-
private static final String STYLE_COLOR_PROPERTY = "style.color";
19-
20-
private static final String BATCH_MODE = "B";
21-
22-
private static final String LOG_FILE = "l";
23-
2415
// Source Directory
2516
public static final String SOURCE_DIRECTORY = "src/main/plsql";
2617

@@ -69,32 +60,4 @@ private static Resource buildDirectory(String directory, String includes)
6960
resource.setIncludes(Arrays.asList(includes));
7061
return resource;
7162
}
72-
73-
/**
74-
*
75-
* @return
76-
*/
77-
public static boolean resolveColor()
78-
{
79-
final Map<String, String> env = System.getenv();
80-
String color = env.get(STYLE_COLOR_PROPERTY);
81-
82-
if ("always".equals(color))
83-
{
84-
return true;
85-
}
86-
87-
if ("never".equals(color))
88-
{
89-
return false;
90-
}
91-
92-
if (env.containsKey(BATCH_MODE) || env.containsKey(LOG_FILE))
93-
{
94-
return false;
95-
}
96-
97-
return false;
98-
}
99-
10063
}

0 commit comments

Comments
 (0)