diff --git a/src/it/ISSUE-174/invoker.properties b/src/it/ISSUE-174/invoker.properties new file mode 100644 index 000000000..2f21bb52f --- /dev/null +++ b/src/it/ISSUE-174/invoker.properties @@ -0,0 +1 @@ +invoker.goals=clean license:add-third-party diff --git a/src/it/ISSUE-174/pom.xml b/src/it/ISSUE-174/pom.xml new file mode 100644 index 000000000..7c9bb0da2 --- /dev/null +++ b/src/it/ISSUE-174/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + + org.codehaus.mojo.license.test + ISSUE-174 + @pom.version@ + + Test ISSUE-174 + http://www.mojohaus.org + + + MojoHaus + + + + + The GNU Lesser General Public License, Version 3.0 + http://www.gnu.org/licenses/lgpl-3.0.txt + repo + + + + + UTF-8 + true + gpl_v3 + + + 2019 + + + + groovy + groovy-all + 1.0-jsr-04 + + + nanocontainer + nanocontainer-remoting + 1.0-RC-1 + + + picocontainer + picocontainer + + + picocontainer + picocontainer-gems + + + picocontainer + picocontainer-tck + + + + + + + + + + org.codehaus.mojo + license-maven-plugin + @pom.version@ + + + + + diff --git a/src/it/ISSUE-174/postbuild.groovy b/src/it/ISSUE-174/postbuild.groovy new file mode 100644 index 000000000..73ea1e0d4 --- /dev/null +++ b/src/it/ISSUE-174/postbuild.groovy @@ -0,0 +1,49 @@ +/* + * #%L + * License Maven Plugin + * %% + * Copyright (C) 2008 - 2011 CodeLutin, Codehaus, Tony Chemit, 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 + * . + * #L% + */ +def assertExistsFile(file) +{ + if ( !file.exists() || file.isDirectory() ) + { + println(file.getAbsolutePath() + " file is missing or a directory.") + assert false + } + assert true +} + +def assertContains(file, content, expected) +{ + if ( !content.contains(expected) ) + { + println(expected + " was not found in file [" + file + "]\n :" + content) + return false + } + return true +} + +file = new File(basedir, 'target/generated-sources/license/THIRD-PARTY.txt'); +assertExistsFile(file); + +content = file.text; +assert assertContains(file, content, 'groovy:groovy-all:1.0-jsr-04'); +assert assertContains(file, content, 'nanocontainer:nanocontainer-remoting:1.0-RC-1'); + +return true; diff --git a/src/it/ISSUE-174/src/main/java/org/codehaus/mojo/HelloWorld.java b/src/it/ISSUE-174/src/main/java/org/codehaus/mojo/HelloWorld.java new file mode 100644 index 000000000..5b98df68a --- /dev/null +++ b/src/it/ISSUE-174/src/main/java/org/codehaus/mojo/HelloWorld.java @@ -0,0 +1,33 @@ +package org.codehaus.mojo; + +/* + * #%L + * License Maven Plugin + * %% + * Copyright (C) 2017 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 + * . + * #L% + */ + +public class HelloWorld +{ + + public static void main( String[] args ) + { + System.out.println( "Hello World." ); + } + +} diff --git a/src/main/java/org/codehaus/mojo/license/api/DefaultDependenciesTool.java b/src/main/java/org/codehaus/mojo/license/api/DefaultDependenciesTool.java index 9f50a4eb3..767e3c1af 100644 --- a/src/main/java/org/codehaus/mojo/license/api/DefaultDependenciesTool.java +++ b/src/main/java/org/codehaus/mojo/license/api/DefaultDependenciesTool.java @@ -257,6 +257,23 @@ public SortedMap loadProjectDependencies( ResolvedProjectD depMavenProject = mavenProjectBuilder.buildFromRepository( artifact, remoteRepositories, localRepository, true ); depMavenProject.getArtifact().setScope( artifact.getScope() ); + + // In case maven-metadata.xml has different artifactId, groupId or version. + if ( !depMavenProject.getGroupId().equals( artifact.getGroupId() ) ) + { + depMavenProject.setGroupId( artifact.getGroupId() ); + depMavenProject.getArtifact().setGroupId( artifact.getGroupId() ); + } + if ( !depMavenProject.getArtifactId().equals( artifact.getArtifactId() ) ) + { + depMavenProject.setArtifactId( artifact.getArtifactId() ); + depMavenProject.getArtifact().setArtifactId( artifact.getArtifactId() ); + } + if ( !depMavenProject.getVersion().equals( artifact.getVersion() ) ) + { + depMavenProject.setVersion( artifact.getVersion() ); + depMavenProject.getArtifact().setVersion( artifact.getVersion() ); + } } catch ( ProjectBuildingException e ) {