Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 174 #190

Merged
merged 1 commit into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/it/ISSUE-174/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=clean license:add-third-party
72 changes: 72 additions & 0 deletions src/it/ISSUE-174/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>ISSUE-174</artifactId>
<version>@pom.version@</version>

<name>Test ISSUE-174</name>
<url>http://www.mojohaus.org</url>

<organization>
<name>MojoHaus</name>
</organization>

<licenses>
<license>
<name>The GNU Lesser General Public License, Version 3.0</name>
<url>http://www.gnu.org/licenses/lgpl-3.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<license.useJavaNoReformatCommentStartTag>true</license.useJavaNoReformatCommentStartTag>
<license.licenseName>gpl_v3</license.licenseName>
</properties>

<inceptionYear>2019</inceptionYear>

<dependencies>
<dependency>
<groupId>groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>1.0-jsr-04</version>
</dependency>
<dependency>
<groupId>nanocontainer</groupId>
<artifactId>nanocontainer-remoting</artifactId>
<version>1.0-RC-1</version>
<exclusions>
<exclusion>
<groupId>picocontainer</groupId>
<artifactId>picocontainer</artifactId>
</exclusion>
<exclusion>
<groupId>picocontainer</groupId>
<artifactId>picocontainer-gems</artifactId>
</exclusion>
<exclusion>
<groupId>picocontainer</groupId>
<artifactId>picocontainer-tck</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>@pom.version@</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
49 changes: 49 additions & 0 deletions src/it/ISSUE-174/postbuild.groovy
Original file line number Diff line number Diff line change
@@ -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
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #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;
33 changes: 33 additions & 0 deletions src/it/ISSUE-174/src/main/java/org/codehaus/mojo/HelloWorld.java
Original file line number Diff line number Diff line change
@@ -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
* <http://www.gnu.org/licenses/lgpl-3.0.html>.
* #L%
*/

public class HelloWorld
{

public static void main( String[] args )
{
System.out.println( "Hello World." );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,23 @@ public SortedMap<String, MavenProject> 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() );
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not particularly happy about setting fields returned by a Maven component. It smells after side effects, like we recently fixed in #145 . But let's try, maybe it will work.

}
catch ( ProjectBuildingException e )
{
Expand Down