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.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
agabrys committed Aug 3, 2016
2 parents 6d8c24d + b6dbd97 commit 3d27c63
Show file tree
Hide file tree
Showing 17 changed files with 276 additions and 121 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Directory Content Maven Plugin Changelog

## 1.0.1
Bugs:
* Fixed logging Mojo parameters

[See documentation](http://directory-content-maven-plugin.projects.gabrys.biz/1.0.1/)

## 1.0
Initial release.

[See documentation](http://directory-content-maven-plugin.projects.gabrys.biz/1.0/)
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# Directory Content Maven Plugin
# About
[![License BSD 3-Clause](https://img.shields.io/badge/license-BSD%203--Clause-blue.svg)](http://directory-content-maven-plugin.projects.gabrys.biz/license.txt)
[![Build Status](https://travis-ci.org/gabrysbiz/directory-content-maven-plugin.svg?branch=master)](https://travis-ci.org/gabrysbiz/directory-content-maven-plugin)

Provides a collection of tools for working with directories.

# Goals Overview
* [directory-content:copy](http://directory-content-maven-plugin.projects.gabrys.biz/1.0/copy-mojo.html) - copies files to directory
* [directory-content:transformList](http://directory-content-maven-plugin.projects.gabrys.biz/1.0/transformList-mojo.html) - transforms files list to a document using [XSLT](http://www.w3.org/TR/xslt) technology
* [directory-content:transformMetadata](http://directory-content-maven-plugin.projects.gabrys.biz/1.0/transformMetadata-mojo.html) - transforms files metadata to documents using [XSLT](http://www.w3.org/TR/xslt) technology
* [directory-content:copy](http://directory-content-maven-plugin.projects.gabrys.biz/1.0.1/copy-mojo.html) - copies files to directory
* [directory-content:transformList](http://directory-content-maven-plugin.projects.gabrys.biz/1.0.1/transformList-mojo.html) - transforms files list to a document using [XSLT](http://www.w3.org/TR/xslt) technology
* [directory-content:transformMetadata](http://directory-content-maven-plugin.projects.gabrys.biz/1.0.1/transformMetadata-mojo.html) - transforms files metadata to documents using [XSLT](http://www.w3.org/TR/xslt) technology

# Requirements
The plugin to run requires:
* Java 5.0 or higher
* Maven 2.0.11 or higher

# Usage
General instructions on how to use the Directory Content Maven Plugin can be found on the [usage](http://directory-content-maven-plugin.projects.gabrys.biz/1.0/usage.html) page. Some more specific use cases are described in the examples given below. Last but not least, users occasionally contribute additional examples, tips or errata to the plugin's [wiki](https://github.com/gabrysbiz/directory-content-maven-plugin/wiki) page.
General instructions on how to use the Directory Content Maven Plugin can be found on the [usage](http://directory-content-maven-plugin.projects.gabrys.biz/1.0.1/usage.html) page. Some more specific use cases are described in the examples given below. Last but not least, users occasionally contribute additional examples, tips or errata to the plugin's [wiki](https://github.com/gabrysbiz/directory-content-maven-plugin/wiki) page.

In case you still have questions regarding the plugin's usage, please have a look at the [FAQ](http://directory-content-maven-plugin.projects.gabrys.biz/1.0/faq.html).
In case you still have questions regarding the plugin's usage, please have a look at the [FAQ](http://directory-content-maven-plugin.projects.gabrys.biz/1.0.1/faq.html).

If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in the [issue tracker](http://directory-content-maven-plugin.projects.gabrys.biz/1.0/issue-tracking.html). When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from the [source repository](http://directory-content-maven-plugin.projects.gabrys.biz/1.0/source-repository.html) and will find supplementary information in the [guide to helping with Maven](http://maven.apache.org/guides/development/guide-helping.html).
If you feel like the plugin is missing a feature or has a defect, you can fill a feature request or bug report in the [issue tracker](http://directory-content-maven-plugin.projects.gabrys.biz/1.0.1/issue-tracking.html). When creating a new issue, please provide a comprehensive description of your concern. Especially for fixing bugs it is crucial that the developers can reproduce your problem. For this reason, entire debug logs, POMs or most preferably little demo projects attached to the issue are very much appreciated. Of course, patches are welcome, too. Contributors can check out the project from the [source repository](http://directory-content-maven-plugin.projects.gabrys.biz/1.0.1/source-repository.html) and will find supplementary information in the [guide to helping with Maven](http://maven.apache.org/guides/development/guide-helping.html).

# Examples
To provide you with better understanding of some usages of the Directory Content Maven Plugin, you can take a look into the following examples:
* [Using include/exclude patterns](http://directory-content-maven-plugin.projects.gabrys.biz/1.0/examples/patterns.html)
* [Copies files from source to output directory](http://directory-content-maven-plugin.projects.gabrys.biz/1.0/examples/copy.html)
* [Transform files list to file with JavaScript imports](http://directory-content-maven-plugin.projects.gabrys.biz/1.0/examples/transform-list.html)
* [Transform files metadata to download files](http://directory-content-maven-plugin.projects.gabrys.biz/1.0/examples/transform-metadata.html)
* [Using include/exclude patterns](http://directory-content-maven-plugin.projects.gabrys.biz/1.0.1/examples/patterns.html)
* [Copies files from source to output directory](http://directory-content-maven-plugin.projects.gabrys.biz/1.0.1/examples/copy.html)
* [Transform files list to file with JavaScript imports](http://directory-content-maven-plugin.projects.gabrys.biz/1.0.1/examples/transform-list.html)
* [Transform files metadata to download files](http://directory-content-maven-plugin.projects.gabrys.biz/1.0.1/examples/transform-metadata.html)

You can also fetch example projects from [GitHub](https://github.com/gabrysbiz/directory-content-maven-plugin-examples).
63 changes: 37 additions & 26 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

<groupId>biz.gabrys.maven.plugins</groupId>
<artifactId>directory-content-maven-plugin</artifactId>
<version>1.0</version>
<version>1.0.1</version>
<packaging>maven-plugin</packaging>
<name>Directory Content Maven Plugin</name>
<description>Provides a collection of tools for working with directories.</description>
<url>http://directory-content-maven-plugin.projects.gabrys.biz/1.0/</url>
<url>http://directory-content-maven-plugin.projects.gabrys.biz/1.0.1/</url>

<inceptionYear>2015</inceptionYear>
<organization>
Expand Down Expand Up @@ -89,7 +89,7 @@
<dependency>
<groupId>biz.gabrys.maven</groupId>
<artifactId>plugin-utils</artifactId>
<version>1.2</version>
<version>1.3.0</version>
</dependency>

<dependency>
Expand Down Expand Up @@ -130,13 +130,17 @@
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
</plugin>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<version>3.5.1</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
Expand All @@ -152,7 +156,7 @@
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-jxr-plugin</artifactId>
Expand All @@ -163,23 +167,23 @@
</plugin>
<plugin>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.8.1</version>
<version>2.9</version>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<version>3.0.1</version>
</plugin>
<plugin>
<artifactId>maven-site-plugin</artifactId>
<version>3.4</version>
<version>3.5.1</version>
</plugin>
<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>2.4</version>
<version>3.0.1</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<version>2.19.1</version>
</plugin>
<plugin>
<groupId>com.mycila</groupId>
Expand All @@ -201,7 +205,7 @@
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<version>0.7.7.201606060606</version>
<configuration>
<rules>
<rule>
Expand Down Expand Up @@ -235,21 +239,6 @@
</execute>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<versionRange>[0,)</versionRange>
<goals>
<goal>prepare-agent</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
Expand Down Expand Up @@ -296,11 +285,33 @@
</executions>
</plugin>
<plugin>
<!-- call mvn package site to generate page -->
<artifactId>maven-site-plugin</artifactId>
<configuration>
<validate>true</validate>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>site</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy todir="${project.build.directory}/site/files">
<fileset dir="${project.build.directory}">
<include name="${project.artifactId}-${project.version}.jar" />
<include name="${project.artifactId}-${project.version}-sources.jar" />
</fileset>
</copy>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
package biz.gabrys.maven.plugins.directory.content;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

import org.apache.maven.plugin.AbstractMojo;
Expand All @@ -24,8 +22,8 @@
import biz.gabrys.maven.plugin.util.io.FileScanner;
import biz.gabrys.maven.plugin.util.io.ScannerFactory;
import biz.gabrys.maven.plugin.util.io.ScannerPatternFormat;
import biz.gabrys.maven.plugin.util.timer.SystemTimer;
import biz.gabrys.maven.plugin.util.timer.Timer;
import biz.gabrys.maven.plugin.util.parameter.ParametersLogBuilder;
import biz.gabrys.maven.plugin.util.parameter.sanitizer.SimpleSanitizer;

/**
* Parent class for all plugin goals.
Expand Down Expand Up @@ -66,8 +64,7 @@ abstract class AbstractPluginMojo extends AbstractMojo {
/**
* Defines inclusion and exclusion fileset patterns format. Available options:
* <ul>
* <li><b>ant</b> - <a href="http://ant.apache.org/">Ant</a>
* <a href="http://ant.apache.org/manual/dirtasks.html#patterns">patterns</a></li>
* <li><b>ant</b> - <a href="http://ant.apache.org/manual/dirtasks.html#patterns">Ant patterns</a></li>
* <li><b>regex</b> - regular expressions (use '/' as path separator)</li>
* </ul>
* @since 1.0
Expand Down Expand Up @@ -95,24 +92,23 @@ abstract class AbstractPluginMojo extends AbstractMojo {
protected String[] excludes = new String[0];

private void logParameters() {
if (getLog().isDebugEnabled()) {
getLog().debug("Job parameters:");
getLog().debug("\tskip = " + skip);
getLog().debug(String.format("\tverbose = %s (calculated: true)", verbose));
getLog().debug("\tsourceDirectory = " + sourceDirectory);
getLog().debug("\tfilesetPatternFormat = " + filesetPatternFormat);
getLog().debug("\tincludes = " + Arrays.toString(includes));
getLog().debug("\texcludes = " + Arrays.toString(excludes));
final Collection<String> parameters = new ArrayList<String>();
fillParametersForLogger(parameters);
for (final String parameter : parameters) {
getLog().debug('\t' + parameter);
}
getLog().debug("");
if (!getLog().isDebugEnabled()) {
return;
}

final ParametersLogBuilder logger = new ParametersLogBuilder(getLog());
logger.append("skip", skip);
logger.append("verbose", verbose, new SimpleSanitizer(verbose, Boolean.TRUE));
logger.append("force", force);
logger.append("sourceDirectory", sourceDirectory);
logger.append("filesetPatternFormat", filesetPatternFormat);
logger.append("includes", includes);
logger.append("excludes", excludes);
fillParameters(logger);
logger.debug();
}

protected abstract void fillParametersForLogger(Collection<String> parameters);
protected abstract void fillParameters(ParametersLogBuilder logger);

private void calculateParameters() {
if (getLog().isDebugEnabled()) {
Expand All @@ -121,7 +117,6 @@ private void calculateParameters() {
}

public final void execute() throws MojoFailureException {
final Timer timer = SystemTimer.getStartedTimer();
logParameters();
if (skip) {
getLog().info("Skipping job execution");
Expand All @@ -138,9 +133,6 @@ public final void execute() throws MojoFailureException {
return;
}
execute(files);
if (verbose) {
getLog().info("Finished in " + timer.stop());
}
}

private Collection<File> getFiles() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;

import biz.gabrys.maven.plugin.util.parameter.ParametersLogBuilder;
import biz.gabrys.maven.plugin.util.parameter.sanitizer.SimpleSanitizer;

/**
* Parent class for all goals related with <a href="http://www.w3.org/TR/xslt">XSLT</a> transformation.
* @since 1.0
Expand Down Expand Up @@ -47,15 +50,15 @@ abstract class AbstractTransformMojo extends AbstractPluginMojo {
protected String separator;

@Override
protected void fillParametersForLogger(final Collection<String> parameters) {
parameters.add("encoding = " + encoding);
if (separator != null) {
parameters.add("separator = " + separator);
} else {
parameters.add(String.format("separator = null (calculated: %s)", File.separator));
}
protected final void fillParameters(final ParametersLogBuilder logger) {
logger.append("xsltFile", xsltFile);
logger.append("encoding", encoding);
logger.append("separator", separator, new SimpleSanitizer(separator != null, File.separator));
fillParameters2(logger);
}

protected abstract void fillParameters2(ParametersLogBuilder logger);

@Override
protected final void execute(final Collection<File> files) throws MojoFailureException {
if (separator == null) {
Expand All @@ -64,5 +67,5 @@ protected final void execute(final Collection<File> files) throws MojoFailureExc
execute2(files);
}

protected abstract void execute2(final Collection<File> files) throws MojoFailureException;
protected abstract void execute2(Collection<File> files) throws MojoFailureException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;

import biz.gabrys.maven.plugin.util.timer.SystemTimer;
import biz.gabrys.maven.plugin.util.timer.Timer;
import biz.gabrys.maven.plugin.util.parameter.ParametersLogBuilder;

/**
* Copies files from source to output directory.
Expand All @@ -40,8 +39,8 @@ public class CopyMojo extends AbstractPluginMojo {
protected File outputDirectory;

@Override
protected void fillParametersForLogger(final Collection<String> parameters) {
parameters.add("outputDirectory = " + outputDirectory);
protected void fillParameters(final ParametersLogBuilder logger) {
logger.append("outputDirectory", outputDirectory);
}

@Override
Expand All @@ -66,18 +65,14 @@ private void copy(final File source, final File destination) throws MojoFailureE
return;
}

Timer timer = null;
if (verbose) {
getLog().info("Coping the file: " + source.getAbsolutePath());
timer = SystemTimer.getStartedTimer();
getLog().info(String.format("Copying %s to %s", source.getAbsolutePath(), destination.getAbsolutePath()));
}
try {
FileUtils.copyFile(source, destination);
} catch (final IOException e) {
throw new MojoFailureException("Cannot copy file to: " + destination.getAbsolutePath(), e);
}
if (timer != null) {
getLog().info("Finished in " + timer.stop());
final String message = String.format("Cannot copy %s to %s", source.getAbsolutePath(), destination.getAbsolutePath());
throw new MojoFailureException(message, e);
}
}
}
Loading

0 comments on commit 3d27c63

Please sign in to comment.