Skip to content
This repository has been archived by the owner on Mar 15, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/1.4.1'
Browse files Browse the repository at this point in the history
# Conflicts:
#	README.md
#	pom.xml
  • Loading branch information
agabrys committed Oct 8, 2017
2 parents a7bdf51 + ec28d31 commit a838c3f
Show file tree
Hide file tree
Showing 10 changed files with 153 additions and 34 deletions.
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@ language: java
script: mvn -e clean install site
jdk:
- oraclejdk8
- oraclejdk7
- openjdk7
- openjdk6
38 changes: 38 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
properties([[
$class: 'BuildDiscarderProperty',
strategy: [
$class: 'LogRotator',
artifactDaysToKeepStr: '-1',
artifactNumToKeepStr: '10',
daysToKeepStr: '-1',
numToKeepStr: '10'
]
]])

node {
timestamps {
stage('Pre Build Cleanup') {
step($class: 'WsCleanup')
}
stage('Checkout') {
checkout scm
}

withMaven(maven: 'MVN-3', jdk: 'JDK-8', mavenLocalRepo: '.repository') {
stage('Build') {
sh 'mvn -e install site -DskipTests'
}
stage('Test') {
sh 'mvn -e test'
junit 'target/surefire-reports/TEST-*.xml'
}
}

stage('Archive') {
archiveArtifacts artifacts: 'target/*.jar', fingerprint: true
}
stage('Post Build Cleanup') {
step($class: 'WsCleanup')
}
}
}
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
[![Build Status](https://travis-ci.org/gabrysbiz/maven-plugin-utils.svg?branch=master)](https://travis-ci.org/gabrysbiz/maven-plugin-utils)

Maven Plugin Utils is a Java library which contains utilities for [Maven 2](https://maven.apache.org/) plugins. It contains tools to:
* scan directories for files and create a virtual (not physical) destination file in the output directory based on the source (see [biz.gabrys.maven.plugin.util.io](http://maven-plugin-utils.projects.gabrys.biz/1.4.0/apidocs/index.html?biz/gabrys/maven/plugin/util/io/package-summary.html) package)
* log Mojos parameters (see [biz.gabrys.maven.plugin.util.parameter](http://maven-plugin-utils.projects.gabrys.biz/1.4.0/apidocs/index.html?biz/gabrys/maven/plugin/util/parameter/package-summary.html) package)
* manage classpath (see [biz.gabrys.maven.plugin.util.classpath](http://maven-plugin-utils.projects.gabrys.biz/1.4.0/apidocs/index.html?biz/gabrys/maven/plugin/util/classpath/package-summary.html) package)
* count execution time (see [biz.gabrys.maven.plugin.util.timer](http://maven-plugin-utils.projects.gabrys.biz/1.4.0/apidocs/index.html?biz/gabrys/maven/plugin/util/timer/package-summary.html) package)
* scan directories for files and create a virtual (not physical) destination file in the output directory based on the source (see [biz.gabrys.maven.plugin.util.io](http://maven-plugin-utils.projects.gabrys.biz/1.4.1/apidocs/index.html?biz/gabrys/maven/plugin/util/io/package-summary.html) package)
* log Mojos parameters (see [biz.gabrys.maven.plugin.util.parameter](http://maven-plugin-utils.projects.gabrys.biz/1.4.1/apidocs/index.html?biz/gabrys/maven/plugin/util/parameter/package-summary.html) package)
* manage classpath (see [biz.gabrys.maven.plugin.util.classpath](http://maven-plugin-utils.projects.gabrys.biz/1.4.1/apidocs/index.html?biz/gabrys/maven/plugin/util/classpath/package-summary.html) package)
* count execution time (see [biz.gabrys.maven.plugin.util.timer](http://maven-plugin-utils.projects.gabrys.biz/1.4.1/apidocs/index.html?biz/gabrys/maven/plugin/util/timer/package-summary.html) package)

Read [API documentation](http://maven-plugin-utils.projects.gabrys.biz/1.4.0/apidocs/) for more information.
Read [API documentation](http://maven-plugin-utils.projects.gabrys.biz/1.4.1/apidocs/) for more information.

# Requirements
The library to run requires:
* Java 5.0 or higher
* Third-Party Dependencies ([see list](http://maven-plugin-utils.projects.gabrys.biz/1.4.0/dependencies.html))
* Third-Party Dependencies ([see list](http://maven-plugin-utils.projects.gabrys.biz/1.4.1/dependencies.html))

# Download
You can download the library from [this page](http://maven-plugin-utils.projects.gabrys.biz/1.4.0/download.html)
or using various [dependency management tools](http://maven-plugin-utils.projects.gabrys.biz/1.4.0/dependency-info.html).
You can download the library from [this page](http://maven-plugin-utils.projects.gabrys.biz/1.4.1/download.html)
or using various [dependency management tools](http://maven-plugin-utils.projects.gabrys.biz/1.4.1/dependency-info.html).
17 changes: 9 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

<groupId>biz.gabrys.maven</groupId>
<artifactId>plugin-utils</artifactId>
<version>1.4.0</version>
<version>1.4.1</version>
<name>Maven Plugin Utils</name>
<description>A Java library which contains utilities for Maven 2 plugins.</description>
<url>http://maven-plugin-utils.projects.gabrys.biz/1.4.0/</url>
<url>http://maven-plugin-utils.projects.gabrys.biz/1.4.1/</url>

<inceptionYear>2015</inceptionYear>
<organization>
Expand Down Expand Up @@ -57,7 +57,7 @@
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
</repository>
</distributionManagement>

Expand Down Expand Up @@ -101,6 +101,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<!-- latest compatible with JDK 1.5 -->
<version>1.10.19</version>
<scope>test</scope>
</dependency>
Expand All @@ -119,7 +120,7 @@
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
Expand Down Expand Up @@ -158,19 +159,19 @@
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.1</version>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.5.1</version>
<version>3.6</version>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19.1</version>
<version>2.20.1</version>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
Expand All @@ -192,7 +193,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.7.201606060606</version>
<version>0.7.9</version>
<configuration>
<rules>
<rule>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ public LoggingFileFilter(final IOFileFilter filter, final Log logger) {
*/
public boolean accept(final File file) {
final boolean accepted = filter.accept(file);
if (!logger.isDebugEnabled()) {
return accepted;
}
LoggerUtils.debugInclusion(logger, file, accepted);
return accepted;
}
Expand All @@ -64,10 +61,9 @@ public boolean accept(final File file) {
*/
public boolean accept(final File dir, final String name) {
final boolean accepted = filter.accept(dir, name);
if (!logger.isDebugEnabled()) {
return accepted;
if (logger.isDebugEnabled()) {
LoggerUtils.debugInclusion(logger, new File(dir, name), accepted);
}
LoggerUtils.debugInclusion(logger, new File(dir, name), accepted);
return accepted;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,18 @@ protected String createParameterValue(final Container container) {

final ValueToStringConverter converter = container.getConverter();
final Object value = container.getValue();
line.append(converter.convert(value));
final String valueText = String.valueOf(converter.convert(value));
line.append(valueText);

final ValueSanitizer sanitizer = container.getSanitizer();
if (!sanitizer.isValid(value)) {
line.append(" (calculated: ");
final Object correctedValue = sanitizer.sanitize(value);
line.append(converter.convert(correctedValue));
line.append(')');
final Object calculatedValue = sanitizer.sanitize(value);
final String calculatedValueText = String.valueOf(converter.convert(calculatedValue));
if (!valueText.equals(calculatedValueText)) {
line.append(" (calculated: ");
line.append(calculatedValueText);
line.append(')');
}
}
return line.toString();
}
Expand Down
2 changes: 1 addition & 1 deletion src/site/site.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<skin>
<groupId>org.apache.maven.skins</groupId>
<artifactId>maven-fluido-skin</artifactId>
<version>1.5</version>
<version>1.6</version>
</skin>
<custom>
<fluidoSkin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void accept_loggerIsEnabled_logInfo() {

Mockito.verify(filter).accept(file);
Mockito.verify(fileFilter).accept(file);
Mockito.verify(logger, Mockito.times(2)).isDebugEnabled();
Mockito.verify(logger).isDebugEnabled();
Mockito.verify(file).isFile();
Mockito.verify(file).getAbsolutePath();
Mockito.verify(logger).debug(Matchers.anyString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,4 +367,79 @@ public void createParameterValue_valueIsNotValid() {
Mockito.verifyNoMoreInteractions(builder, converter, sanitizer);
Mockito.verifyZeroInteractions(logger);
}

@Test
public void createParameterValue_valueIsNotValid_sanitizedValueIsTheSameAsValue() {
final Log logger = Mockito.mock(Log.class);
final ParametersLogBuilder builder = Mockito.spy(new ParametersLogBuilder(logger));

final String object = "object";

final Container container = Mockito.mock(Container.class);
Mockito.when(container.getValue()).thenReturn(object);

final ValueToStringConverter converter = Mockito.mock(ValueToStringConverter.class);
final String incorrectValue = "incorrect";
Mockito.when(converter.convert(object)).thenReturn(incorrectValue);
Mockito.when(container.getConverter()).thenReturn(converter);

final ValueSanitizer sanitizer = Mockito.mock(ValueSanitizer.class);
Mockito.when(sanitizer.isValid(object)).thenReturn(Boolean.FALSE);
final String sanitized = "sanitized";
Mockito.when(sanitizer.sanitize(object)).thenReturn(sanitized);
Mockito.when(container.getSanitizer()).thenReturn(sanitizer);

Mockito.when(converter.convert(sanitized)).thenReturn(incorrectValue);

final String value = builder.createParameterValue(container);

Assert.assertEquals("Value.", incorrectValue, value);
Mockito.verify(builder).createParameterValue(container);
Mockito.verify(container).getConverter();
Mockito.verify(container).getValue();
Mockito.verify(converter).convert(object);
Mockito.verify(container).getSanitizer();
Mockito.verify(sanitizer).isValid(object);
Mockito.verify(sanitizer).sanitize(object);
Mockito.verify(converter).convert(sanitized);
Mockito.verifyNoMoreInteractions(builder, converter, sanitizer);
Mockito.verifyZeroInteractions(logger);
}

@Test
public void createParameterValue_valueIsNull_sanitizedValueIsNullText() {
final Log logger = Mockito.mock(Log.class);
final ParametersLogBuilder builder = Mockito.spy(new ParametersLogBuilder(logger));

final String object = "object";

final Container container = Mockito.mock(Container.class);
Mockito.when(container.getValue()).thenReturn(object);

final ValueToStringConverter converter = Mockito.mock(ValueToStringConverter.class);
Mockito.when(converter.convert(object)).thenReturn(null);
Mockito.when(container.getConverter()).thenReturn(converter);

final ValueSanitizer sanitizer = Mockito.mock(ValueSanitizer.class);
Mockito.when(sanitizer.isValid(object)).thenReturn(Boolean.FALSE);
final String sanitized = "sanitized";
Mockito.when(sanitizer.sanitize(object)).thenReturn(sanitized);
Mockito.when(container.getSanitizer()).thenReturn(sanitizer);

Mockito.when(converter.convert(sanitized)).thenReturn("null");

final String value = builder.createParameterValue(container);

Assert.assertEquals("Value.", "null", value);
Mockito.verify(builder).createParameterValue(container);
Mockito.verify(container).getConverter();
Mockito.verify(container).getValue();
Mockito.verify(converter).convert(object);
Mockito.verify(container).getSanitizer();
Mockito.verify(sanitizer).isValid(object);
Mockito.verify(sanitizer).sanitize(object);
Mockito.verify(converter).convert(sanitized);
Mockito.verifyNoMoreInteractions(builder, converter, sanitizer);
Mockito.verifyZeroInteractions(logger);
}
}
13 changes: 10 additions & 3 deletions xdocs/changelog.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,38 @@
</properties>

<body>
<section id="release-1.4.1" name="Release 1.4.1">
<p>Bugs:</p>
<ul>
<li>Stopped logging calculated value when it is the same as the primary value</li>
</ul>
</section>
<section id="release-1.4.0" name="Release 1.4.0">
<p>Features:</p>
<ul>
<li>
Added
<a href="apidocs/index.html?biz/gabrys/maven/plugin/util/classpath/ContextClassLoaderExtender.html">
<a href="http://maven-plugin-utils.projects.gabrys.biz/1.4.0/apidocs/index.html?biz/gabrys/maven/plugin/util/classpath/ContextClassLoaderExtender.html">
ContextClassLoaderExtender
</a>
responsible for adding Maven project dependencies to classpath
</li>
<li>
Added
<a href="apidocs/index.html?biz/gabrys/maven/plugin/util/parameter/ParameterUtils.html">
<a href="http://maven-plugin-utils.projects.gabrys.biz/1.4.0/apidocs/index.html?biz/gabrys/maven/plugin/util/parameter/ParameterUtils.html">
ParameterUtils
</a>
which provides tools to work with method parameters
</li>
<li>
Separation of the seconds and milliseconds in the
<a href="apidocs/index.html?biz/gabrys/maven/plugin/util/timer/Time.html">
<a href="http://maven-plugin-utils.projects.gabrys.biz/1.4.0/apidocs/index.html?biz/gabrys/maven/plugin/util/timer/Time.html">
Time#toString()
</a>
method
</li>
</ul>
<p><a href="http://maven-plugin-utils.projects.gabrys.biz/1.4.0/">See documentation</a></p>
</section>
<section id="release-1.3.0" name="Release 1.3.0">
<p>Features:</p>
Expand Down

0 comments on commit a838c3f

Please sign in to comment.