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

[MNG-6405] Fix basedir in MavenProject.deepCopy #225

Merged
merged 4 commits into from Apr 16, 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
Expand Up @@ -1207,7 +1207,8 @@ private void deepCopy( MavenProject project )
// disown the parent

// copy fields
setFile( project.getFile() );
file = project.file;
basedir = project.basedir;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that these assignments are actually unnecessary when called from clone, since the fields are already set correctly by super.clone. They would however be needed if called from MavenProject.<init>(MavenProject); since that copy constructor is apparently neither called anywhere in Maven itself nor tested, I wonder if it even works.


// don't need a deep copy, they don't get modified or added/removed to/from - but make them unmodifiable to be
// sure!
Expand Down
Expand Up @@ -177,6 +177,17 @@ public void testCloneWithActiveProfile()
activeProfilesClone );
}

public void testCloneWithBaseDir()
throws Exception
{
File f = getFileForClasspathResource( "canonical-pom.xml" );
MavenProject projectToClone = getProject( f );
projectToClone.setPomFile( new File( new File( f.getParentFile(), "target" ), "flattened.xml" ) );
MavenProject clonedProject = projectToClone.clone();
assertEquals( "POM file is preserved across clone", projectToClone.getFile(), clonedProject.getFile() );
assertEquals( "Base directory is preserved across clone", projectToClone.getBasedir(), clonedProject.getBasedir() );
}

public void testUndefinedOutputDirectory()
throws Exception
{
Expand Down