mirror of
https://github.com/apache/maven.git
synced 2025-02-28 21:59:13 +00:00
adding scheleton for a real complete testcase.
This test works using a 2-modules project and contains any direct and transitive dependency type. Mvn is executed using a command line, so the test is actually disabled in pom.xml until a better solution is found (the test works with the latest installed version of the eclipse plugin). Note that expected files for module-2 are not correct yet (first of all, test #8 need to be fixed) git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@329838 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6a40b74bca
commit
3662d4abd8
@ -1,4 +1,5 @@
|
||||
<project>
|
||||
<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 ">
|
||||
<parent>
|
||||
<artifactId>maven-plugin-parent</artifactId>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -30,10 +31,30 @@
|
||||
<artifactId>maven-artifact</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-settings</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-container-default</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<excludes>
|
||||
<exclude>**/Abstract*TestCase.java</exclude>
|
||||
<exclude>**/EclipsePluginMasterProjectTest.java</exclude><!-- need to be fixed -->
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -0,0 +1,192 @@
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.maven.plugin.eclipse;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public abstract class AbstractEclipsePluginTestCase
|
||||
extends PlexusTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Execute the eclipse:eclipse goal on a test project and verify generated files.
|
||||
* @param projectName project directory
|
||||
* @param outputDir output dir (if null it's the same as the project)
|
||||
* @throws Exception any exception generated during test
|
||||
*/
|
||||
protected void testProject( String projectName, File outputDir )
|
||||
throws Exception
|
||||
{
|
||||
File basedir = getTestFile( "src/test/projects/" + projectName );
|
||||
|
||||
MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
||||
|
||||
EclipsePlugin plugin = new EclipsePlugin();
|
||||
|
||||
File repo = getTestFile( "src/test/repository" );
|
||||
|
||||
ArtifactRepositoryLayout localRepositoryLayout = (ArtifactRepositoryLayout) lookup(
|
||||
ArtifactRepositoryLayout.ROLE,
|
||||
"legacy" );
|
||||
|
||||
ArtifactRepository localRepository = new DefaultArtifactRepository( "local",
|
||||
"file://" + repo.getAbsolutePath(),
|
||||
localRepositoryLayout );
|
||||
|
||||
MavenProject project = builder.buildWithDependencies( new File( basedir, "pom.xml" ), localRepository, null );
|
||||
|
||||
File projectOutputDir = basedir;
|
||||
|
||||
if ( outputDir == null )
|
||||
{
|
||||
outputDir = basedir;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDir.mkdirs();
|
||||
|
||||
projectOutputDir = new File( outputDir, project.getArtifactId() );
|
||||
}
|
||||
|
||||
// Shouldn't PlexusTestCase at least offer a predefined log instance?
|
||||
// if ( log.isDebugEnabled() )
|
||||
// {
|
||||
// log.debug( "basedir: " + basedir + "\noutputdir: " + outputDir + "\nprojectOutputDir: " + projectOutputDir );
|
||||
// }
|
||||
|
||||
plugin.setOutputDir( outputDir );
|
||||
|
||||
for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
artifact.setFile( new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) ) );
|
||||
}
|
||||
|
||||
plugin.setProject( project );
|
||||
plugin.setOutputDirectory( project.getBuild().getOutputDirectory() );
|
||||
|
||||
plugin.setLocalRepository( localRepository );
|
||||
|
||||
plugin.setArtifactFactory( (ArtifactFactory) lookup( ArtifactFactory.ROLE ) );
|
||||
plugin.setArtifactResolver( (ArtifactResolver) lookup( ArtifactResolver.ROLE ) );
|
||||
plugin.setRemoteArtifactRepositories( new ArrayList( 0 ) );
|
||||
|
||||
List projectNatures = new ArrayList();
|
||||
projectNatures.add( "org.eclipse.jdt.core.javanature" );
|
||||
plugin.setProjectnatures( projectNatures );
|
||||
|
||||
List buildcommands = new ArrayList();
|
||||
buildcommands.add( "org.eclipse.jdt.core.javabuilder" );
|
||||
plugin.setBuildcommands( buildcommands );
|
||||
|
||||
plugin.setClasspathContainers( new ArrayList() );
|
||||
|
||||
plugin.setDownloadSources( true );
|
||||
|
||||
// @todo how to test injected parameters?
|
||||
|
||||
plugin.execute();
|
||||
|
||||
assertFileEquals( localRepository.getBasedir(), new File( basedir, "project" ), new File( projectOutputDir,
|
||||
".project" ) );
|
||||
|
||||
assertFileEquals( localRepository.getBasedir(), new File( basedir, "classpath" ), new File( projectOutputDir,
|
||||
".classpath" ) );
|
||||
|
||||
assertFileEquals( localRepository.getBasedir(), new File( basedir, "wtpmodules" ), new File( projectOutputDir,
|
||||
".wtpmodules" ) );
|
||||
|
||||
if ( new File( basedir, "settings" ).exists() )
|
||||
{
|
||||
assertFileEquals( localRepository.getBasedir(), new File( basedir, "settings" ),
|
||||
new File( basedir, ".settings/org.eclipse.jdt.core.prefs" ) );
|
||||
}
|
||||
}
|
||||
|
||||
protected void assertFileEquals( String mavenRepo, File expectedFile, File actualFile )
|
||||
throws IOException
|
||||
{
|
||||
List expectedLines = getLines( mavenRepo, expectedFile );
|
||||
|
||||
List actualLines = getLines( mavenRepo, actualFile );
|
||||
|
||||
for ( int i = 0; i < expectedLines.size(); i++ )
|
||||
{
|
||||
String expected = expectedLines.get( i ).toString();
|
||||
|
||||
// replace some vars in the expected line, to account
|
||||
// for absolute paths that are different on each installation.
|
||||
|
||||
expected = StringUtils.replace( expected, "${basedir}", getBasedir().replace( '\\', '/' ) );
|
||||
|
||||
if ( actualLines.size() <= i )
|
||||
{
|
||||
fail( "Too few lines in the actual file. Was " + actualLines.size() + ", expected: "
|
||||
+ expectedLines.size() );
|
||||
}
|
||||
|
||||
String actual = actualLines.get( i ).toString();
|
||||
|
||||
if ( expected.startsWith( "#" ) && actual.startsWith( "#" ) )
|
||||
{
|
||||
//ignore comments, for settings file
|
||||
continue;
|
||||
}
|
||||
|
||||
assertEquals( "Checking line #" + ( i + 1 ), expected, actual );
|
||||
}
|
||||
|
||||
assertTrue( "Unequal number of lines.", expectedLines.size() == actualLines.size() );
|
||||
}
|
||||
|
||||
private List getLines( String mavenRepo, File file )
|
||||
throws IOException
|
||||
{
|
||||
List lines = new ArrayList();
|
||||
|
||||
BufferedReader reader = new BufferedReader( new FileReader( file ) );
|
||||
|
||||
String line;
|
||||
|
||||
while ( ( line = reader.readLine() ) != null )
|
||||
{
|
||||
lines.add( line );//StringUtils.replace( line, "#ArtifactRepositoryPath#", mavenRepo.replace( '\\', '/' ) ) );
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
}
|
@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.maven.plugin.eclipse;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
import org.apache.maven.settings.MavenSettingsBuilder;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.codehaus.plexus.util.IOUtil;
|
||||
import org.codehaus.plexus.util.cli.CommandLineException;
|
||||
import org.codehaus.plexus.util.cli.CommandLineUtils;
|
||||
import org.codehaus.plexus.util.cli.Commandline;
|
||||
import org.codehaus.plexus.util.cli.DefaultConsumer;
|
||||
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
|
||||
import org.codehaus.plexus.util.xml.XMLWriter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Master test for eclipse .classpath and .wtpmodules generation.
|
||||
* </p>
|
||||
* <p>
|
||||
* This test use a 2 modules project with all the mvn dependencies flavours (direct, transitive, with
|
||||
* compile/test/provided/system scope, required and optional, artifacts and modules).
|
||||
* </p>
|
||||
* <p>
|
||||
* In order to fully test the eclipse plugin execution in a such complex environment mvn is executed from a command line.
|
||||
* Mvn is started using a custom settings.xml file, created on the fly. The custom settings.xml only adds a mirror for
|
||||
* the central repository which is actually a local (file://) repository for loading files from <code>src/test/m2repo</code>
|
||||
* </p>
|
||||
* <p>The following is the base layout of modules/dependencies. The actual test is to check generated files for module-2</p>
|
||||
* <pre>
|
||||
*
|
||||
* +----------------+ +-----------------+ +-----------------+
|
||||
* /| module 1 (jar) | ----> | refproject | ----> | deps-refproject |
|
||||
* / +----------------+ +-----------------+ +-----------------+
|
||||
* / ^
|
||||
* root | (depends on)
|
||||
* \ |
|
||||
* \ +----------------+ +-----------------+ +-----------------+
|
||||
* \| module 2 (war) | ----> | direct | ----> | deps-direct |
|
||||
* +----------------+ +-----------------+ +-----------------+
|
||||
*
|
||||
* </pre>
|
||||
* @todo a know problem with this approach is that tests are running with the installed version of the plugin! Don't
|
||||
* enable test in pom.xml at the moment or you will never be able to build.
|
||||
* @author Fabrizio Giustina
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EclipsePluginMasterProjectTest
|
||||
extends AbstractEclipsePluginTestCase
|
||||
{
|
||||
public void testMasterProject()
|
||||
throws Exception
|
||||
{
|
||||
File basedir = getTestFile( "src/test/projects/master-test" );
|
||||
|
||||
executeMaven2CommandLine( basedir );
|
||||
|
||||
assertFileEquals( null, new File( basedir, "module-1/project" ), new File( basedir, "module-1/.project" ) );
|
||||
assertFileEquals( null, new File( basedir, "module-1/classpath" ), new File( basedir, "module-1/.classpath" ) );
|
||||
assertFileEquals( null, new File( basedir, "module-1/wtpmodules" ), new File( basedir, "module-1/.wtpmodules" ) );
|
||||
|
||||
// the real test: this should include any sort of direct/transitive dependency handled by mvn
|
||||
assertFileEquals( null, new File( basedir, "module-2/project" ), new File( basedir, "module-2/.project" ) );
|
||||
assertFileEquals( null, new File( basedir, "module-2/classpath" ), new File( basedir, "module-2/.classpath" ) );
|
||||
assertFileEquals( null, new File( basedir, "module-2/wtpmodules" ), new File( basedir, "module-2/.wtpmodules" ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute mvn from command line.
|
||||
* @throws Exception any exception caught is thrown during tests
|
||||
*/
|
||||
protected void executeMaven2CommandLine( File workingDir )
|
||||
throws Exception
|
||||
{
|
||||
|
||||
Commandline cmd = createMaven2CommandLine( workingDir );
|
||||
|
||||
int exitCode = CommandLineUtils.executeCommandLine( cmd, new DefaultConsumer(), new DefaultConsumer() );
|
||||
|
||||
if ( exitCode != 0 )
|
||||
{
|
||||
throw new CommandLineException( "The command line failed. Exit code: " + exitCode );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to create a m2 command line from a given working directory.
|
||||
*
|
||||
* @param workingDir a not null working directory.
|
||||
* @return the m2 command line
|
||||
* @throws Exception any exception caught is thrown during tests
|
||||
*/
|
||||
protected Commandline createMaven2CommandLine( File workingDir )
|
||||
throws Exception
|
||||
{
|
||||
|
||||
assertNotNull( "workingDir can't be null", workingDir );
|
||||
assertTrue( "workingDir must exist", workingDir.exists() );
|
||||
|
||||
// read default settings and extract local repository path
|
||||
MavenSettingsBuilder settingsBuilder = (MavenSettingsBuilder) lookup( MavenSettingsBuilder.ROLE );
|
||||
Settings defaultSettings = settingsBuilder.buildSettings();
|
||||
|
||||
// prepare a temporary settings.xml
|
||||
File settings = File.createTempFile( "settings", ".xml" );
|
||||
settings.deleteOnExit();
|
||||
Writer w = new FileWriter( settings );
|
||||
XMLWriter writer = new PrettyPrintXMLWriter( w );
|
||||
writer.startElement( "settings" );
|
||||
|
||||
// keep default local repository
|
||||
writer.startElement( "localRepository" );
|
||||
writer.writeText( defaultSettings.getLocalRepository() );
|
||||
writer.endElement();
|
||||
|
||||
writer.startElement( "interactiveMode" );
|
||||
writer.writeText( "false" );
|
||||
writer.endElement();
|
||||
|
||||
writer.startElement( "mirrors" );
|
||||
writer.startElement( "mirror" );
|
||||
|
||||
// add a file mirror, so that dependencies are loaded from the plugin directory
|
||||
writer.startElement( "id" );
|
||||
writer.writeText( "localtest" );
|
||||
writer.endElement();
|
||||
writer.startElement( "url" );
|
||||
writer.writeText( "file://" + getBasedir().replace( '\\', '/' ) + "/src/test/m2repo" );
|
||||
writer.endElement();
|
||||
writer.startElement( "mirrorOf" );
|
||||
writer.writeText( "central" );
|
||||
writer.endElement();
|
||||
|
||||
writer.endElement();
|
||||
writer.endElement();
|
||||
|
||||
writer.endElement();
|
||||
IOUtil.close( w );
|
||||
|
||||
Commandline cmd = new Commandline();
|
||||
|
||||
cmd.setWorkingDirectory( workingDir.getAbsolutePath() );
|
||||
|
||||
cmd.setExecutable( "mvn" );
|
||||
cmd.createArgument().setValue( "-s" + settings.getAbsolutePath() );
|
||||
cmd.createArgument().setValue( "-e" );
|
||||
|
||||
cmd.createArgument().setValue( "eclipse:clean" );
|
||||
cmd.createArgument().setValue( "eclipse:eclipse" );
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
}
|
@ -1,5 +1,3 @@
|
||||
package org.apache.maven.plugin.eclipse;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
@ -16,31 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.artifact.Artifact;
|
||||
import org.apache.maven.artifact.factory.ArtifactFactory;
|
||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.DefaultArtifactRepository;
|
||||
import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
|
||||
import org.apache.maven.artifact.resolver.ArtifactResolver;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.apache.maven.project.MavenProjectBuilder;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
package org.apache.maven.plugin.eclipse;
|
||||
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EclipsePluginTest
|
||||
extends PlexusTestCase
|
||||
extends AbstractEclipsePluginTestCase
|
||||
{
|
||||
public void testProject1()
|
||||
throws Exception
|
||||
@ -91,145 +72,4 @@ public void testProject7()
|
||||
// testProject( "project-8", null );
|
||||
// }
|
||||
|
||||
private void testProject( String projectName, File outputDir )
|
||||
throws Exception
|
||||
{
|
||||
File basedir = getTestFile( "src/test/projects/" + projectName );
|
||||
|
||||
MavenProjectBuilder builder = (MavenProjectBuilder) lookup( MavenProjectBuilder.ROLE );
|
||||
|
||||
EclipsePlugin plugin = new EclipsePlugin();
|
||||
|
||||
File repo = getTestFile( "src/test/repository" );
|
||||
|
||||
ArtifactRepositoryLayout localRepositoryLayout = (ArtifactRepositoryLayout) lookup(
|
||||
ArtifactRepositoryLayout.ROLE,
|
||||
"legacy" );
|
||||
|
||||
ArtifactRepository localRepository = new DefaultArtifactRepository( "local",
|
||||
"file://" + repo.getAbsolutePath(),
|
||||
localRepositoryLayout );
|
||||
|
||||
MavenProject project = builder.buildWithDependencies( new File( basedir, "pom.xml" ), localRepository, null );
|
||||
|
||||
File projectOutputDir = basedir;
|
||||
|
||||
if ( outputDir == null )
|
||||
{
|
||||
outputDir = basedir;
|
||||
}
|
||||
else
|
||||
{
|
||||
outputDir.mkdirs();
|
||||
|
||||
projectOutputDir = new File( outputDir, project.getArtifactId() );
|
||||
}
|
||||
|
||||
// Shouldn't PlexusTestCase at least offer a predefined log instance?
|
||||
// if ( log.isDebugEnabled() )
|
||||
// {
|
||||
// log.debug( "basedir: " + basedir + "\noutputdir: " + outputDir + "\nprojectOutputDir: " + projectOutputDir );
|
||||
// }
|
||||
|
||||
plugin.setOutputDir( outputDir );
|
||||
|
||||
for ( Iterator it = project.getArtifacts().iterator(); it.hasNext(); )
|
||||
{
|
||||
Artifact artifact = (Artifact) it.next();
|
||||
artifact.setFile( new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) ) );
|
||||
}
|
||||
|
||||
plugin.setProject( project );
|
||||
plugin.setOutputDirectory( project.getBuild().getOutputDirectory() );
|
||||
|
||||
plugin.setLocalRepository( localRepository );
|
||||
|
||||
plugin.setArtifactFactory( (ArtifactFactory) lookup( ArtifactFactory.ROLE ) );
|
||||
plugin.setArtifactResolver( (ArtifactResolver) lookup( ArtifactResolver.ROLE ) );
|
||||
plugin.setRemoteArtifactRepositories( new ArrayList( 0 ) );
|
||||
|
||||
List projectNatures = new ArrayList();
|
||||
projectNatures.add( "org.eclipse.jdt.core.javanature" );
|
||||
plugin.setProjectnatures( projectNatures );
|
||||
|
||||
List buildcommands = new ArrayList();
|
||||
buildcommands.add( "org.eclipse.jdt.core.javabuilder" );
|
||||
plugin.setBuildcommands( buildcommands );
|
||||
|
||||
plugin.setClasspathContainers( new ArrayList() );
|
||||
|
||||
plugin.setDownloadSources( true );
|
||||
|
||||
// @todo how to test injected parameters?
|
||||
|
||||
plugin.execute();
|
||||
|
||||
assertFileEquals( localRepository.getBasedir(), new File( basedir, "project" ), new File( projectOutputDir,
|
||||
".project" ) );
|
||||
|
||||
assertFileEquals( localRepository.getBasedir(), new File( basedir, "classpath" ), new File( projectOutputDir,
|
||||
".classpath" ) );
|
||||
|
||||
assertFileEquals( localRepository.getBasedir(), new File( basedir, "wtpmodules" ), new File( projectOutputDir,
|
||||
".wtpmodules" ) );
|
||||
|
||||
if ( new File( basedir, "settings" ).exists() )
|
||||
{
|
||||
assertFileEquals( localRepository.getBasedir(), new File( basedir, "settings" ),
|
||||
new File( basedir, ".settings/org.eclipse.jdt.core.prefs" ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void assertFileEquals( String mavenRepo, File expectedFile, File actualFile )
|
||||
throws IOException
|
||||
{
|
||||
List expectedLines = getLines( mavenRepo, expectedFile );
|
||||
|
||||
List actualLines = getLines( mavenRepo, actualFile );
|
||||
|
||||
for ( int i = 0; i < expectedLines.size(); i++ )
|
||||
{
|
||||
String expected = expectedLines.get( i ).toString();
|
||||
|
||||
// replace some vars in the expected line, to account
|
||||
// for absolute paths that are different on each installation.
|
||||
|
||||
expected = StringUtils.replace( expected, "${basedir}", getBasedir().replace( '\\', '/' ) );
|
||||
|
||||
if ( actualLines.size() <= i )
|
||||
{
|
||||
fail( "Too few lines in the actual file. Was " + actualLines.size() + ", expected: "
|
||||
+ expectedLines.size() );
|
||||
}
|
||||
|
||||
String actual = actualLines.get( i ).toString();
|
||||
|
||||
if ( expected.startsWith( "#" ) && actual.startsWith( "#" ) )
|
||||
{
|
||||
//ignore comments, for settings file
|
||||
continue;
|
||||
}
|
||||
|
||||
assertEquals( "Checking line #" + ( i + 1 ), expected, actual );
|
||||
}
|
||||
|
||||
assertTrue( "Unequal number of lines.", expectedLines.size() == actualLines.size() );
|
||||
}
|
||||
|
||||
private List getLines( String mavenRepo, File file )
|
||||
throws IOException
|
||||
{
|
||||
List lines = new ArrayList();
|
||||
|
||||
BufferedReader reader = new BufferedReader( new FileReader( file ) );
|
||||
|
||||
String line;
|
||||
|
||||
while ( ( line = reader.readLine() ) != null )
|
||||
{
|
||||
lines.add( line );//StringUtils.replace( line, "#ArtifactRepositoryPath#", mavenRepo.replace( '\\', '/' ) ) );
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
}
|
||||
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-direct-compile</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-direct-optional</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-direct-test</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-direct-test</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-refproject-compile</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-refproject-optional</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-refproject-test</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-refproject-test</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,32 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>direct-compile</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-direct-compile</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-direct-test</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-direct-provided</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-direct-optional</artifactId>
|
||||
<version>1.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>direct-optional</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>direct-test</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>direct-test</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,42 @@
|
||||
<?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>
|
||||
<packaging>jar</packaging>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>module-1</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>module-1</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>refproject-compile</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>refproject-test</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>refproject-provided</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>refproject-optional</artifactId>
|
||||
<version>1.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>refproject-sysdep</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/refproject-sysdep.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,32 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>refproject-compile</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-refproject-compile</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-refproject-test</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-refproject-provided</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>deps-refproject-optional</artifactId>
|
||||
<version>1.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>refproject-optional</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>refproject-test</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
</project>
|
Binary file not shown.
@ -0,0 +1,9 @@
|
||||
<project>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>refproject-test</artifactId>
|
||||
<version>1.0</version>
|
||||
<distributionManagement>
|
||||
<status>verified</status>
|
||||
</distributionManagement>
|
||||
</project>
|
@ -0,0 +1,10 @@
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="var" path="M2_REPO/eclipsetest/refproject-compile/1.0/refproject-compile-1.0.jar"/>
|
||||
<classpathentry kind="var" path="M2_REPO/eclipsetest/refproject-test/1.0/refproject-test-1.0.jar"/>
|
||||
<classpathentry kind="lib" path="${basedir}/module-1/refproject-sysdep.jar"/>
|
||||
<classpathentry kind="var" path="M2_REPO/eclipsetest/refproject-provided/1.0/refproject-provided-1.0.jar"/>
|
||||
<classpathentry kind="var" path="M2_REPO/eclipsetest/refproject-optional/1.0/refproject-optional-1.0.jar"/>
|
||||
</classpath>
|
@ -0,0 +1,42 @@
|
||||
<?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>
|
||||
<packaging>jar</packaging>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>module-1</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>module-1</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>refproject-compile</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>refproject-test</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>refproject-provided</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>refproject-optional</artifactId>
|
||||
<version>1.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>refproject-sysdep</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/refproject-sysdep.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,14 @@
|
||||
<projectDescription>
|
||||
<name>module-1</name>
|
||||
<comment/>
|
||||
<projects/>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments/>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DummyClass
|
||||
{
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
<project-modules id="moduleCoreId">
|
||||
<wb-module deploy-name="module-1">
|
||||
<module-type module-type-id="jst.utility">
|
||||
<property name="java-output-path" value="/target/classes"/>
|
||||
</module-type>
|
||||
</wb-module>
|
||||
</project-modules>
|
@ -0,0 +1,12 @@
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src/main/java"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="var" path="M2_REPO/eclipsetest/direct-provided/1.0/direct-provided-1.0.jar"/>
|
||||
<classpathentry kind="lib" path="${basedir}/module-2/direct-sysdep.jar"/>
|
||||
<classpathentry kind="var" path="M2_REPO/eclipsetest/refproject-compile/1.0/refproject-compile-1.0.jar"/>
|
||||
<classpathentry kind="var" path="M2_REPO/eclipsetest/direct-test/1.0/direct-test-1.0.jar"/>
|
||||
<classpathentry kind="lib" path="${basedir}/module-1/refproject-sysdep.jar"/>
|
||||
<classpathentry kind="src" path="/module-1"/>
|
||||
<classpathentry kind="var" path="M2_REPO/eclipsetest/direct-compile/1.0/direct-compile-1.0.jar"/>
|
||||
</classpath>
|
@ -0,0 +1,48 @@
|
||||
<?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>
|
||||
<packaging>war</packaging>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>module-2</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>module-2</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<!-- module -->
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>module-1</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>direct-compile</artifactId>
|
||||
<version>1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>direct-test</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>direct-provided</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>direct-optional</artifactId>
|
||||
<version>1.0</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>direct-sysdep</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/direct-sysdep.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -0,0 +1,16 @@
|
||||
<projectDescription>
|
||||
<name>module-2</name>
|
||||
<comment/>
|
||||
<projects>
|
||||
<project>module-1</project>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments/>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DummyClass
|
||||
{
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
<project-modules id="moduleCoreId">
|
||||
<wb-module deploy-name="module-2">
|
||||
<module-type module-type-id="jst.web">
|
||||
<version>2.4</version>
|
||||
<property name="context-root" value="module-2"/>
|
||||
</module-type>
|
||||
<wb-resource deploy-path="/" source-path="/src/main/webapp"/>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/var/M2_REPO/eclipsetest/direct-provided/1.0/direct-provided-1.0.jar">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/var/M2_REPO/D:/apps/maven-2/maven-plugins/maven-eclipse-plugin/src/test/projects/master-test/module-2/direct-sysdep.jar">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/var/M2_REPO/eclipsetest/refproject-compile/1.0/refproject-compile-1.0.jar">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/var/M2_REPO/eclipsetest/direct-test/1.0/direct-test-1.0.jar">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/var/M2_REPO/D:/apps/maven-2/maven-plugins/maven-eclipse-plugin/src/test/projects/master-test/module-1/refproject-sysdep.jar">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/resource/module-1/module-1">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<dependent-module deploy-path="/WEB-INF/lib" handle="module:/classpath/var/M2_REPO/eclipsetest/direct-compile/1.0/direct-compile-1.0.jar">
|
||||
<dependency-type>uses</dependency-type>
|
||||
</dependent-module>
|
||||
<wb-resource deploy-path="/WEB-INF/classes" source-path="src/main/java"/>
|
||||
</wb-module>
|
||||
</project-modules>
|
@ -0,0 +1,14 @@
|
||||
<?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>
|
||||
<packaging>pom</packaging>
|
||||
<groupId>eclipsetest</groupId>
|
||||
<artifactId>master-test</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>master</name>
|
||||
<modules>
|
||||
<module>module-1</module>
|
||||
<module>module-2</module>
|
||||
</modules>
|
||||
</project>
|
Loading…
x
Reference in New Issue
Block a user