Maybe I'm missing something, but why not use a Maven selector for the IT?
[1]Something like invoker.maven.version = 3.0- Robert [1]
http://maven.apache.org/plugins/maven-invoker-plugin/examples/selector-conditions.html
From: [email protected]
To: [email protected]
Date: Sun, 6 Jan 2013 03:48:25 -0600
Subject: [mojo-scm] [17833] trunk/mojo/license-maven-plugin: MLICENSE-53 Allow
" includedLicenses" to be specified in sub-tags ( do the same for
excludedLicense parameter)
[17833] trunk/mojo/license-maven-plugin: MLICENSE-53 Allow "includedLicenses"
to be specified in sub-tags (do the same for excludedLicense parameter)
Revision 17833
Author tchemit
Date 2013-01-06 03:48:25 -0600 (Sun, 06 Jan 2013)
Log Message
MLICENSE-53 Allow "includedLicenses" to be specified in sub-tags (do the same
for excludedLicense parameter)
Modified Paths
trunk/mojo/license-maven-plugin/pom.xml
trunk/mojo/license-maven-plugin/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java
Added Paths
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/goals.txt
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/pom.xml
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/postbuild.groovy
trunk/mojo/license-maven-plugin/src/main/java/org/codehaus/mojo/license/utils/StringToList.java
Diff
Modified: trunk/mojo/license-maven-plugin/pom.xml (17832 => 17833)
--- trunk/mojo/license-maven-plugin/pom.xml 2013-01-05 14:36:00 UTC (rev
17832)
+++ trunk/mojo/license-maven-plugin/pom.xml 2013-01-06 09:48:25 UTC (rev
17833)
@@ -130,6 +130,9 @@
<invokerPluginVersion>1.8</invokerPluginVersion>
<javadocPluginVersion>2.9</javadocPluginVersion>
+ <!-- By default exclude this pom in IT, will be removed for maven-3 (see
MLICENSE-60)-->
+
<pomExclude221Pattern>aggregate-add-third-party/global-db/pom.xml</pomExclude221Pattern>
+
</properties>
<dependencies>
@@ -404,11 +407,25 @@
<profiles>
<profile>
+ <id>maven-3</id>
+ <activation>
+ <file>
+ <!-- This employs that the basedir expression is only recognized by
Maven 3.x (see MNG-2363) -->
+ <exists>${basedir}</exists>
+ </file>
+ </activation>
+ <properties>
+ <!-- No pom to exclude for MLICENSE-60 when maven 3 -->
+
<pomExclude221Pattern>aggregate-add-third-party/global-db/pom.xml</pomExclude221Pattern>
+ </properties>
+ </profile>
+
+ <!--profile>
<id>disable-2.2.1-its</id>
<properties>
<pomExclude221Pattern>aggregate-add-third-party/global-db/pom.xml</pomExclude221Pattern>
</properties>
- </profile>
+ </profile-->
<profile>
<id>run-its</id>
<activation>
Property changes:
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53
Added: svn:ignore
.iml
.ipr
.iws
.idea
Added:
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/goals.txt (0
=> 17833)
---
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/goals.txt
(rev 0)
+++
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/goals.txt
2013-01-06 09:48:25 UTC (rev 17833)
@@ -0,0 +1 @@
+clean generate-resources
\ No newline at end of file
Property changes on:
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/goals.txt
___________________________________________________________________
Added: svn:keywords
Added: svn:eol-style
Added:
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/pom.xml (0
=> 17833)
--- trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/pom.xml
(rev 0)
+++ trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/pom.xml
2013-01-06 09:48:25 UTC (rev 17833)
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ #%L
+ License Maven Plugin
+ %%
+ Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit
+ %%
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation, either version 3 of the
+ License, or (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Lesser Public License for more details.
+
+ You should have received a copy of the GNU General Lesser Public
+ License along with this program. If not, see
+ <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ #L%
+ -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.codehaus.mojo.license.test</groupId>
+ <artifactId>test-MLICENSE-53</artifactId>
+ <version>@pom.version@</version>
+
+ <name>License Test :: MLICENSE-53</name>
+
+ <properties>
+ <!--<licenseVersion>@pom.version@</licenseVersion>-->
+ <licenseVersion>1.4-SNAPSHOT</licenseVersion>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <license.verbose>true</license.verbose>
+ </properties>
+ <build>
+
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+
+ <configuration><failIfWarning>true</failIfWarning></configuration>
+ <executions>
+ <execution>
+ <id>with-single-string-included-licenses</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>add-third-party</goal>
+ </goals>
+ <configuration>
+ <includedLicenses>The Apache Software License, Version
2.0|Lesser General Public License (LGPL) v 3.0</includedLicenses>
+
<thirdPartyFilename>with-single-string-included-licenses-THIRD-PARTY.txt</thirdPartyFilename>
+ </configuration>
+ </execution>
+ <execution>
+ <id>with-string-list-included-licenses</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>add-third-party</goal>
+ </goals>
+ <configuration>
+ <includedLicenses>
+ <includedLicense>
+ Lesser General Public License (LGPL) v 3.0
+ </includedLicense>
+ <includedLicense>
+ The Apache Software License, Version 2.0
+ </includedLicense>
+ </includedLicenses>
+
<thirdPartyFilename>with-string-list-included-licenses-THIRD-PARTY.txt</thirdPartyFilename>
+ </configuration>
+ </execution>
+ <execution>
+ <id>with-single-string-excluded-licenses</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>add-third-party</goal>
+ </goals>
+ <configuration>
+ <excludedLicenses>The Apache Software License, Version 2.0
Fake|Lesser General Public License (LGPL) v 3.0 Fake</excludedLicenses>
+
<thirdPartyFilename>with-single-string-excluded-licenses-THIRD-PARTY.txt</thirdPartyFilename>
+ </configuration>
+ </execution>
+ <execution>
+ <id>with-string-list-excluded-licenses</id>
+ <phase>generate-resources</phase>
+ <goals>
+ <goal>add-third-party</goal>
+ </goals>
+ <configuration>
+ <excludedLicenses>
+ <excludedLicense>
+ Lesser General Public License (LGPL) v 3.0 Fake
+ </excludedLicense>
+ <excludedLicense>
+ The Apache Software License, Version 2.0 Fake
+ </excludedLicense>
+ </excludedLicenses>
+
<thirdPartyFilename>with-string-list-excluded-licenses-THIRD-PARTY.txt</thirdPartyFilename>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ <pluginManagement>
+ <plugins>
+
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>license-maven-plugin</artifactId>
+ <version>${licenseVersion}</version>
+ </plugin>
+ </plugins>
+ </pluginManagement>
+ </build>
+
+ <dependencies>
+
+ <!-- apache v2 license -->
+ <dependency>
+ <groupId>commons-logging</groupId>
+ <artifactId>commons-logging</artifactId>
+ <version>1.1.1</version>
+ </dependency>
+
+ <!-- lgpl v3 license -->
+ <dependency>
+ <groupId>org.nuiton.processor</groupId>
+ <artifactId>nuiton-processor</artifactId>
+ <!--<version>@processorVersion@</version>-->
+ <version>1.3</version>
+ </dependency>
+
+ <!--dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ <version>1.0-alpha-9-stable-1</version>
+ </dependency-->
+
+ </dependencies>
+
+</project>
+
+
Property changes on:
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/pom.xml
___________________________________________________________________
Added: svn:keywords
Added: svn:eol-style
Added:
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/postbuild.groovy
(0 => 17833)
---
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/postbuild.groovy
(rev 0)
+++
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/postbuild.groovy
2013-01-06 09:48:25 UTC (rev 17833)
@@ -0,0 +1,22 @@
+/*
+ * #%L
+ * License Maven Plugin
+ * %%
+ * Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+return true;
\ No newline at end of file
Property changes on:
trunk/mojo/license-maven-plugin/src/it/add-third-party/MLICENSE-53/postbuild.groovy
___________________________________________________________________
Added: svn:keywords
Added: svn:eol-style
Modified:
trunk/mojo/license-maven-plugin/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java
(17832 => 17833)
---
trunk/mojo/license-maven-plugin/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java
2013-01-05 14:36:00 UTC (rev 17832)
+++
trunk/mojo/license-maven-plugin/src/main/java/org/codehaus/mojo/license/AbstractAddThirdPartyMojo.java
2013-01-06 09:48:25 UTC (rev 17833)
@@ -39,10 +39,10 @@
import org.codehaus.mojo.license.utils.FileUtil;
import org.codehaus.mojo.license.utils.MojoHelper;
import org.codehaus.mojo.license.utils.SortedProperties;
+import org.codehaus.mojo.license.utils.StringToList;
import java.io.File;
import java.io.IOException;
-import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -118,26 +118,56 @@
private List<String> licenseMerges;
/**
- * To specify some licenses to include (separated by {@code |}).
+ * To specify some licenses to include.
* <p/>
* If this parameter is filled and a license is not in this {@code
whitelist} then build will failed when property
* {@link #failIfWarning} is <tt>true</tt>.
+ * <p/>
+ * Since version {@code 1.4}, there is two ways to fill this parameter :
+ * <ul>
+ * <li>A simple string (separated by {@code |}), the way to use by
property configuration:
+ *
<pre><includedLicenses>licenseA|licenseB</includedLicenses></pre> or
+ * <pre>-Dlicense.includedLicenses=licenseA|licenseB</pre>
+ * </li>
+ * <li>A list of string (can only be used in plugin configuration, not via
property configuration)
+ * <pre>
+ * <includedLicenses>
+ * <includedLicense>licenseA</includedLicense>
+ * <includedLicenses>licenseB</includedLicense>
+ * </includedLicenses></pre>
+ * </li>
+ * </ul>
*
* @since 1.1
*/
@Parameter( property = "license.includedLicenses", defaultValue = "" )
- private String includedLicenses;
+ private IncludedLicenses includedLicenses;
/**
- * To specify some licenses to exclude (separated by {@code |}).
+ * To specify some licenses to exclude.
* <p/>
* If a such license is found then build will failed when property
* {@link #failIfWarning} is <tt>true</tt>.
+ * <p/>
+ * Since version {@code 1.4}, there is two ways to fill this parameter :
+ * <ul>
+ * <li>A simple string (separated by {@code |}), the way to use by
property configuration:
+ *
<pre><excludedLicenses>licenseA|licenseB</excludedLicenses></pre> or
+ * <pre>-Dlicense.excludedLicenses=licenseA|licenseB</pre>
+ * </li>
+ * <li>A list of string (can only be used in plugin configuration, not via
property configuration)
+ * <pre>
+ * <excludedLicenses>
+ * <excludedLicense>licenseA</excludedLicense>
+ * <excludedLicense>licenseB</excludedLicense>
+ * </excludedLicenses></pre>
+ * </li>
+ * </ul>
*
* @since 1.1
*/
@Parameter( property = "license.excludedLicenses", defaultValue = "" )
- private String excludedLicenses;
+ private ExcludedLicenses excludedLicenses;
/**
* The path of the bundled third party file to produce when
@@ -207,7 +237,7 @@
/**
* The set of dependencies for the current project, used to locate license
databases.
*/
- @Parameter( property = "project.artifacts", required = true, readonly =
true)
+ @Parameter( property = "project.artifacts", required = true, readonly =
true )
private Set<Artifact> dependencies;
// ----------------------------------------------------------------------
@@ -412,6 +442,42 @@
return doGenerateBundle;
}
+ /**
+ * @return list of license to exclude.
+ */
+ public List<String> getExcludedLicenses()
+ {
+ return excludedLicenses.getData();
+ }
+
+ /**
+ * @return list of license to include.
+ */
+ public List<String> getIncludedLicenses()
+ {
+ return includedLicenses.getData();
+ }
+
+ /**
+ * Fill the {@link #includedLicenses} parameter from a simple string to
split.
+ *
+ * @param includedLicenses license to excludes separated by a {@code |}.
+ */
+ public void setIncludedLicenses( String includedLicenses )
+ {
+ this.includedLicenses = new IncludedLicenses( includedLicenses );
+ }
+
+ /**
+ * Fill the {@link #excludedLicenses} parameter from a simple string to
split.
+ *
+ * @param excludedLicenses license to excludes separated by a {@code |}.
+ */
+ public void setExcludedLicenses( String excludedLicenses )
+ {
+ this.excludedLicenses = new ExcludedLicenses( excludedLicenses );
+ }
+
// ----------------------------------------------------------------------
// Protected Methods
// ----------------------------------------------------------------------
@@ -427,18 +493,6 @@
return helper;
}
- public List<String> getExcludedLicenses()
- {
- String[] split = excludedLicenses == null ? new String[0] :
excludedLicenses.split( "\\s*\\|\\s*" );
- return Arrays.asList( split );
- }
-
- public List<String> getIncludedLicenses()
- {
- String[] split = includedLicenses == null ? new String[0] :
includedLicenses.split( "\\s*\\|\\s*" );
- return Arrays.asList( split );
- }
-
protected boolean checkUnsafeDependencies()
{
SortedSet<MavenProject> unsafeDeps = getUnsafeDependencies();
@@ -534,4 +588,82 @@
}
}
+ /**
+ * Class to fill the {@link #includedLicenses} parameter, from a simple
string to split, or a list of string.
+ * <p/>
+ * TODO-tchemit We should find a way to create a plexus convertor.
+ *
+ * @since 1.4
+ */
+ public static class IncludedLicenses
+ extends StringToList
+ {
+
+ /**
+ * Default constructor used when {@link #includedLicenses} parameter
is configured by a list.
+ */
+ public IncludedLicenses()
+ {
+ }
+
+ /**
+ * Constructor used when {@link #includedLicenses} parameter is
configured by a string to split.
+ *
+ * @param data the string to split to fill the list of data of the
object.
+ */
+ public IncludedLicenses( String data )
+ {
+ super( data );
+ }
+
+ /**
+ * Add a simple a include license to the list.
+ *
+ * @param includeLicense the include license to add.
+ */
+ public void setIncludedLicense( String includeLicense )
+ {
+ addEntryToList( includeLicense );
+ }
+ }
+
+ /**
+ * Class to fill the {@link #excludedLicenses} parameter, from a simple
string to split, or a list of string.
+ * <p/>
+ * TODO-tchemit We should find a way to create a plexus convertor.
+ *
+ * @since 1.4
+ */
+ public static class ExcludedLicenses
+ extends StringToList
+ {
+
+ /**
+ * Default constructor used when {@link #excludedLicenses} parameter
is configured by a list.
+ */
+ public ExcludedLicenses()
+ {
+ }
+
+ /**
+ * Constructor used when {@link #excludedLicenses} parameter is
configured by a string to split.
+ *
+ * @param data the string to split to fill the list of data of the
object.
+ */
+ public ExcludedLicenses( String data )
+ {
+ super( data );
+ }
+
+ /**
+ * Add a simple exclude License to the list.
+ *
+ * @param excludeLicense the excludelicense to add.
+ */
+ public void setExcludedLicense( String excludeLicense )
+ {
+ addEntryToList( excludeLicense );
+ }
+ }
+
}
\ No newline at end of file
Added:
trunk/mojo/license-maven-plugin/src/main/java/org/codehaus/mojo/license/utils/StringToList.java
(0 => 17833)
---
trunk/mojo/license-maven-plugin/src/main/java/org/codehaus/mojo/license/utils/StringToList.java
(rev 0)
+++
trunk/mojo/license-maven-plugin/src/main/java/org/codehaus/mojo/license/utils/StringToList.java
2013-01-06 09:48:25 UTC (rev 17833)
@@ -0,0 +1,68 @@
+package org.codehaus.mojo.license.utils;
+
+/*
+ * #%L
+ * License Maven Plugin
+ * %%
+ * Copyright (C) 2013 CodeLutin, Codehaus, Tony Chemit
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Object to convert in mojo a parameter from a some simple String to a List.
+ * <p/>
+ * See (http://jira.codehaus.org/browse/MLICENSE-53).
+ *
+ * @author tchemit <[email protected]>
+ * @since 1.4
+ */
+public class StringToList
+{
+
+ /**
+ * List of data.
+ */
+ private final List<String> data;
+
+ public StringToList()
+ {
+ data = new ArrayList<String>();
+ }
+
+ public StringToList( String data )
+ {
+ this();
+ for ( String s : data.split( "\\s*\\|\\s*" ) )
+ {
+ addEntryToList( s );
+ }
+ }
+
+ public List<String> getData()
+ {
+ return data;
+ }
+
+ protected void addEntryToList( String data )
+ {
+ this.data.add( data );
+ }
+
+}
Property changes on:
trunk/mojo/license-maven-plugin/src/main/java/org/codehaus/mojo/license/utils/StringToList.java
___________________________________________________________________
Added: svn:keywords
Added: svn:eol-style
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email