From 765bb3381fce95a90aa3a0b668ace988b9876fcb Mon Sep 17 00:00:00 2001 From: Karl-Heinz Marbaise Date: Mon, 27 Oct 2014 20:04:29 +0100 Subject: [PATCH] - Migrated to Java 5 Annotations instead of old style XDoclet based Mojo definitions. --- pom.xml | 405 ++++++++++-------- .../org/lesscss/mojo/AbstractLessCssMojo.java | 13 +- .../java/org/lesscss/mojo/CompileMojo.java | 27 +- src/main/java/org/lesscss/mojo/ListMojo.java | 3 +- 4 files changed, 246 insertions(+), 202 deletions(-) diff --git a/pom.xml b/pom.xml index ee42898..ffe6fa0 100644 --- a/pom.xml +++ b/pom.xml @@ -1,188 +1,229 @@ - + - 4.0.0 - org.lesscss - lesscss-maven-plugin - 1.7.0.1.2-SNAPSHOT - maven-plugin - Official LESS CSS Maven Plugin - Official LESS CSS Maven Plugin - http://github.com/marceloverdijk/lesscss-maven-plugin - - - org.sonatype.oss - oss-parent - 7 - - - - UTF-8 - UTF-8 - - - - - commons-logging - commons-logging - 1.1.1 - - - commons-io - commons-io - 2.4 - - - junit - junit - 4.10 - test - - - org.slf4j - slf4j-api - 1.7.2 - test - - - org.apache.maven - maven-plugin-api - 2.0 - - - org.apache.maven.plugin-testing - maven-plugin-testing-harness - 1.3 - test - - - slf4j-jdk14 - org.slf4j - - - slf4j-nop - org.slf4j - - - - - org.codehaus.plexus - plexus-utils - 3.0 - - - org.lesscss - lesscss - 1.7.0.1.1 - - - org.mockito - mockito-core - 1.9.0 - test - - - org.powermock - powermock-module-junit4 - 1.4.11 - test - - - org.powermock - powermock-api-mockito - 1.4.11 - test - - - org.sonatype.plexus - plexus-build-api - 0.0.7 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - UTF-8 - 1.5 - 1.5 - - - - org.apache.maven.plugins - maven-invoker-plugin - 1.5 - - ${project.build.directory}/it - true - ${project.build.directory}/local-repo - verify - src/it - src/it/settings.xml + 4.0.0 + org.lesscss + lesscss-maven-plugin + 1.7.0.1.2-SNAPSHOT + maven-plugin + Official LESS CSS Maven Plugin + Official LESS CSS Maven Plugin + http://github.com/marceloverdijk/lesscss-maven-plugin + + + org.sonatype.oss + oss-parent + 7 + + + + 2.2.1 + UTF-8 + UTF-8 + + + + + commons-logging + commons-logging + 1.1.1 + + + commons-io + commons-io + 2.4 + + + junit + junit + 4.10 + test + + + org.slf4j + slf4j-api + 1.7.2 + test + + + + org.apache.maven + maven-plugin-api + ${maven.version} + provided + + + + org.apache.maven.plugin-tools + maven-plugin-annotations + 3.3 + provided + + + + org.apache.maven.plugin-testing + maven-plugin-testing-harness + 1.3 + test + + + slf4j-jdk14 + org.slf4j + + + slf4j-nop + org.slf4j + + + + + org.codehaus.plexus + plexus-utils + 3.0 + + + org.lesscss + lesscss + 1.7.0.1.1 + + + org.mockito + mockito-core + 1.9.0 + test + + + org.powermock + powermock-module-junit4 + 1.4.11 + test + + + org.powermock + powermock-api-mockito + 1.4.11 + test + + + org.sonatype.plexus + plexus-build-api + 0.0.7 + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + UTF-8 + 1.5 + 1.5 + + + + org.apache.maven.plugins + maven-invoker-plugin + 1.5 + + ${project.build.directory}/it + true + ${project.build.directory}/local-repo + verify + src/it + src/it/settings.xml - - - - integration-test - - install - run - - - - - - - - - - The Apache Software License, Version 2.0 - http://www.apache.org/licenses/LICENSE-2.0.txt - repo - - - - - - marceloverdijk - Marcel Overdijk - marcel@overdijk.me - - Lead Developer - - +2 - - - cpopov - Christophe Popov - chrpopov.gmail.com - http://uk.linkedin.com/in/hpopov/ - - Developer - - 0 - - - - - GitHub - http://github.com/marceloverdijk/lesscss-maven-plugin/issues - - - - scm:git:git@github.com:marceloverdijk/lesscss-maven-plugin.git - scm:git:git@github.com:marceloverdijk/lesscss-maven-plugin.git - http://github.com/marceloverdijk/lesscss-maven-plugin - - - - 2.0 - - + + + + integration-test + + install + run + + + + + + org.apache.maven.plugins + maven-plugin-plugin + 3.3 + + lesscss + + + + default-descriptor + + descriptor + + process-classes + + + help-descriptor + + helpmojo + + process-classes + + + + + + + + + + The Apache Software License, Version 2.0 + http://www.apache.org/licenses/LICENSE-2.0.txt + repo + + + + + + marceloverdijk + Marcel Overdijk + marcel@overdijk.me + + Lead Developer + + +2 + + + cpopov + Christophe Popov + chrpopov.gmail.com + http://uk.linkedin.com/in/hpopov/ + + Developer + + 0 + + + + + GitHub + http://github.com/marceloverdijk/lesscss-maven-plugin/issues + + + + scm:git:git@github.com:marceloverdijk/lesscss-maven-plugin.git + scm:git:git@github.com:marceloverdijk/lesscss-maven-plugin.git + http://github.com/marceloverdijk/lesscss-maven-plugin + + + + + + + ${maven.version} + diff --git a/src/main/java/org/lesscss/mojo/AbstractLessCssMojo.java b/src/main/java/org/lesscss/mojo/AbstractLessCssMojo.java index b990667..dd96589 100644 --- a/src/main/java/org/lesscss/mojo/AbstractLessCssMojo.java +++ b/src/main/java/org/lesscss/mojo/AbstractLessCssMojo.java @@ -17,6 +17,8 @@ import java.io.File; import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugins.annotations.Component; +import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.plexus.util.Scanner; import org.sonatype.plexus.build.incremental.BuildContext; @@ -27,29 +29,28 @@ */ public abstract class AbstractLessCssMojo extends AbstractMojo { - /** @component */ + @Component protected BuildContext buildContext; /** * The source directory containing the LESS sources. * - * @parameter expression="${lesscss.sourceDirectory}" default-value="${project.basedir}/src/main/less" - * @required */ + @Parameter( defaultValue = "${project.basedir}/src/main/less", property = "lesscss.sourceDirectory", required = true) protected File sourceDirectory; /** * List of files to include. Specified as fileset patterns which are relative to the source directory. Default value is: { "**\/*.less" } * - * @parameter */ + @Parameter protected String[] includes = new String[] { "**/*.less" }; /** * List of files to exclude. Specified as fileset patterns which are relative to the source directory. * - * @parameter */ + @Parameter protected String[] excludes = new String[] {}; /** @@ -69,7 +70,7 @@ protected String[] getIncludedFiles() { * Whether to skip plugin execution. * This makes the build more controllable from profiles. * - * @parameter expression="${lesscss.skip}" default-value="false" */ + @Parameter( defaultValue = "false", property = "lesscss.skip") protected boolean skip; } diff --git a/src/main/java/org/lesscss/mojo/CompileMojo.java b/src/main/java/org/lesscss/mojo/CompileMojo.java index c102b2c..5e23897 100644 --- a/src/main/java/org/lesscss/mojo/CompileMojo.java +++ b/src/main/java/org/lesscss/mojo/CompileMojo.java @@ -20,6 +20,9 @@ import java.util.Arrays; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; import org.codehaus.plexus.util.StringUtils; import org.lesscss.LessCompiler; import org.lesscss.LessException; @@ -30,76 +33,74 @@ * Goal which compiles the LESS sources to CSS stylesheets. * * @author Marcel Overdijk - * @goal compile - * @phase process-sources */ +@Mojo( name = "compile", defaultPhase = LifecyclePhase.PROCESS_RESOURCES, requiresProject = true, threadSafe = true ) public class CompileMojo extends AbstractLessCssMojo { /** * The directory for compiled CSS stylesheets. * - * @parameter expression="${lesscss.outputDirectory}" default-value="${project.build.directory}" - * @required */ + @Parameter( defaultValue = "${project.build.directory}", property = "lesscss.outputDirectory", required = true ) protected File outputDirectory; /** * When true the LESS compiler will compress the CSS stylesheets. * - * @parameter expression="${lesscss.compress}" default-value="false" */ + @Parameter( defaultValue = "false", property = "lesscss.compress" ) private boolean compress; /** * When true the plugin will watch for changes in LESS files and compile if it detects one. * - * @parameter expression="${lesscss.watch}" default-value="false" */ + @Parameter( defaultValue = "false", property = "lesscss.watch" ) protected boolean watch=false; /** * When true the plugin will watch for changes in LESS files and compile if it detects one. * - * @parameter expression="${lesscss.watchInterval}" default-value="1000" */ + @Parameter( defaultValue = "1000", property = "lesscss.watchInterval" ) private int watchInterval=1000; /** * The character encoding the LESS compiler will use for writing the CSS stylesheets. * - * @parameter expression="${lesscss.encoding}" default-value="${project.build.sourceEncoding}" */ + @Parameter( defaultValue = "${project.build.sourceEncoding}", property = "lesscss.encoding" ) private String encoding; /** * When true forces the LESS compiler to always compile the LESS sources. By default LESS sources are only compiled when modified (including imports) or the CSS stylesheet does not exists. * - * @parameter expression="${lesscss.force}" default-value="false" */ + @Parameter( defaultValue = "false", property = "lesscss.force" ) private boolean force; /** * The location of the LESS JavasSript file. * - * @parameter */ + @Parameter private File lessJs; /** * The location of the NodeJS executable. * - * @parameter */ + @Parameter private String nodeExecutable; /** * The format of the output file names. * - * @parameter */ + @Parameter private String outputFileFormat; - private static final String FILE_NAME_FORMAT_PARAMETER_REGEX = "\\{fileName\\}"; + private static final String FILE_NAME_FORMAT_PARAMETER_REGEX = "\\{fileName\\}"; /** * Execute the MOJO. diff --git a/src/main/java/org/lesscss/mojo/ListMojo.java b/src/main/java/org/lesscss/mojo/ListMojo.java index e51556e..bc385ca 100644 --- a/src/main/java/org/lesscss/mojo/ListMojo.java +++ b/src/main/java/org/lesscss/mojo/ListMojo.java @@ -22,14 +22,15 @@ import java.util.Map.Entry; import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Mojo; import org.lesscss.LessSource; /** * Goal which list the LESS sources and its imports. * * @author Marcel Overdijk - * @goal list */ +@Mojo( name = "list" ) public class ListMojo extends AbstractLessCssMojo { /**