Author: brett Date: Thu Sep 15 18:37:39 2005 New Revision: 289359 URL: http://svn.apache.org/viewcvs?rev=289359&view=rev Log: fix eclipse plugin tests
Modified: maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java Modified: maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java?rev=289359&r1=289358&r2=289359&view=diff ============================================================================== --- maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java (original) +++ maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java Thu Sep 15 18:37:39 2005 @@ -30,18 +30,18 @@ /** * A Maven2 plugin which integrates the use of Maven2 with Eclipse. * + * @author <a href="mailto:[EMAIL PROTECTED]">Trygve Laugstøl</a> + * @version $Id$ * @goal eclipse * @requiresDependencyResolution test * @execute phase="generate-sources" - * - * @author <a href="mailto:[EMAIL PROTECTED]">Trygve Laugstøl</a> - * @version $Id$ */ public class EclipsePlugin extends AbstractMojo { /** * The project whose project files to create. + * * @parameter expression="${project}" * @required */ @@ -49,12 +49,14 @@ /** * The currently executed project (can be a reactor project). + * * @parameter expression="${executedProject}" */ private MavenProject executedProject; /** * Local maven repository. + * * @parameter expression="${localRepository}" * @required * @readonly @@ -63,6 +65,7 @@ /** * If the executed project is a reactor project, this will contains the full list of projects in the reactor. + * * @parameter expression="${reactorProjects}" * @required * @readonly @@ -71,6 +74,7 @@ /** * Artifact resolver, needed to download source jars for inclusion in classpath. + * * @parameter expression="${component.org.apache.maven.artifact.resolver.ArtifactResolver}" * @required * @readonly @@ -80,6 +84,7 @@ /** * Artifact factory, needed to download source jars for inclusion in classpath. + * * @parameter expression="${component.org.apache.maven.artifact.factory.ArtifactFactory}" * @required * @readonly @@ -89,6 +94,7 @@ /** * Remote repositories which will be searched for source attachments. + * * @parameter expression="${project.remoteArtifactRepositories}" * @required * @readonly @@ -104,6 +110,7 @@ * <java.lang.String>org.eclipse.wst.common.modulecore.ModuleCoreNature</java.lang.String> * </projectnatures> * </pre> + * * @parameter * @todo default-value="<java.lang.String>org.eclipse.jdt.core.javanature</java.lang.String>" */ @@ -119,6 +126,7 @@ * <java.lang.String>org.eclipse.wst.common.modulecore.ComponentStructuralBuilderDependencyResolver</java.lang.String> * </buildcommands> * </pre> + * * @parameter * @todo default-value="org.eclipse.jdt.core.javabuilder" */ @@ -133,6 +141,7 @@ * <java.lang.String>org.eclipse.jst.j2ee.internal.web.container/artifact</java.lang.String> * </classpathContainers> * </pre> + * * @parameter * @todo default-value=empty list */ @@ -140,19 +149,21 @@ /** * Disables the downloading of source attachments. - * + * * @parameter expression="${eclipse.downloadSources}" */ private boolean downloadSources = false; /** * Eclipse workspace directory. + * * @parameter expression="${eclipse.workspace}" */ private File outputDir; /** * Setter for <code>project</code>. Needed for tests. + * * @param project The MavenProject to set. */ protected void setProject( MavenProject project ) @@ -162,6 +173,7 @@ /** * Setter for <code>localRepository</code>. Needed for tests. + * * @param localRepository The ArtifactRepository to set. */ protected void setLocalRepository( ArtifactRepository localRepository ) @@ -171,6 +183,7 @@ /** * Setter for <code>artifactFactory</code>. Needed for tests. + * * @param artifactFactory The artifactFactory to set. */ protected void setArtifactFactory( ArtifactFactory artifactFactory ) @@ -180,6 +193,7 @@ /** * Setter for <code>artifactResolver</code>. Needed for tests. + * * @param artifactResolver The artifactResolver to set. */ protected void setArtifactResolver( ArtifactResolver artifactResolver ) @@ -189,6 +203,7 @@ /** * Setter for <code>remoteArtifactRepositories</code>. Needed for tests. + * * @param remoteArtifactRepositories The remoteArtifactRepositories to set. */ protected void setRemoteArtifactRepositories( List remoteArtifactRepositories ) @@ -198,6 +213,7 @@ /** * Setter for <code>buildcommands</code>. Needed for tests. + * * @param buildcommands The buildcommands to set. */ protected void setBuildcommands( List buildcommands ) @@ -207,6 +223,7 @@ /** * Setter for <code>classpathContainers</code>. Needed for tests. + * * @param classpathContainers The classpathContainers to set. */ protected void setClasspathContainers( List classpathContainers ) @@ -216,6 +233,7 @@ /** * Setter for <code>projectnatures</code>. Needed for tests. + * * @param projectnatures The projectnatures to set. */ protected void setProjectnatures( List projectnatures ) @@ -225,6 +243,7 @@ /** * Setter for <code>outputDir</code>. Needed for tests. + * * @param outputDir The outputDir to set. */ public void setOutputDir( File outputDir ) @@ -243,7 +262,7 @@ // backwards compat with alpha-2 only executedProject = project; } - + assertNotEmpty( executedProject.getGroupId(), "groupId" ); //$NON-NLS-1$ assertNotEmpty( executedProject.getArtifactId(), "artifactId" ); //$NON-NLS-1$ @@ -286,14 +305,16 @@ { if ( !outputDir.isDirectory() ) { - throw new MojoExecutionException( Messages.getString( "EclipsePlugin.notadir", outputDir ) ); //$NON-NLS-1$ + throw new MojoExecutionException( + Messages.getString( "EclipsePlugin.notadir", outputDir ) ); //$NON-NLS-1$ } outputDir = new File( outputDir, executedProject.getArtifactId() ); if ( !outputDir.isDirectory() && !outputDir.mkdir() ) { - throw new MojoExecutionException( Messages.getString( "EclipsePlugin.cantcreatedir", outputDir ) ); //$NON-NLS-1$ + throw new MojoExecutionException( + Messages.getString( "EclipsePlugin.cantcreatedir", outputDir ) ); //$NON-NLS-1$ } } @@ -327,7 +348,7 @@ localRepository ); getLog().info( Messages.getString( "EclipsePlugin.wrote", //$NON-NLS-1$ - new Object[] { project.getArtifactId(), outputDir.getAbsolutePath() } ) ); + new Object[]{project.getArtifactId(), outputDir.getAbsolutePath()} ) ); } private void assertNotEmpty( String string, String elementName ) @@ -335,7 +356,13 @@ { if ( string == null ) { - throw new EclipsePluginException( Messages.getString( "EclipsePlugin.missingelement", elementName ) ); //$NON-NLS-1$ + throw new EclipsePluginException( + Messages.getString( "EclipsePlugin.missingelement", elementName ) ); //$NON-NLS-1$ } + } + + public void setDownloadSources( boolean downloadSources ) + { + this.downloadSources = downloadSources; } } Modified: maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java?rev=289359&r1=289358&r2=289359&view=diff ============================================================================== --- maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java (original) +++ maven/components/trunk/maven-plugins/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java Thu Sep 15 18:37:39 2005 @@ -16,14 +16,6 @@ * limitations under the License. */ -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; @@ -35,6 +27,14 @@ 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; + /** * @author <a href="mailto:[EMAIL PROTECTED]">Trygve Laugstøl</a> * @version $Id$ @@ -90,11 +90,9 @@ File repo = getTestFile( "src/test/repository" ); ArtifactRepositoryLayout localRepositoryLayout = (ArtifactRepositoryLayout) lookup( - ArtifactRepositoryLayout.ROLE, - "legacy" ); + ArtifactRepositoryLayout.ROLE, "legacy" ); - ArtifactRepository localRepository = new DefaultArtifactRepository( "local", - "file://" + repo.getAbsolutePath(), + ArtifactRepository localRepository = new DefaultArtifactRepository( "local", "file://" + repo.getAbsolutePath(), localRepositoryLayout ); MavenProject project = builder @@ -145,18 +143,20 @@ 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, "project" ), + new File( projectOutputDir, ".project" ) ); - assertFileEquals( localRepository.getBasedir(), new File( basedir, "classpath" ), new File( projectOutputDir, - ".classpath" ) ); + assertFileEquals( localRepository.getBasedir(), new File( basedir, "classpath" ), + new File( projectOutputDir, ".classpath" ) ); - assertFileEquals( localRepository.getBasedir(), new File( basedir, "wtpmodules" ), new File( projectOutputDir, - ".wtpmodules" ) ); + assertFileEquals( localRepository.getBasedir(), new File( basedir, "wtpmodules" ), + new File( projectOutputDir, ".wtpmodules" ) ); if ( new File( basedir, "settings" ).exists() ) { @@ -183,8 +183,8 @@ if ( actualLines.size() <= i ) { - fail( "Too few lines in the actual file. Was " + actualLines.size() + ", expected: " - + expectedLines.size() ); + fail( "Too few lines in the actual file. Was " + actualLines.size() + ", expected: " + + expectedLines.size() ); } String actual = actualLines.get( i ).toString(); @@ -212,7 +212,8 @@ while ( ( line = reader.readLine() ) != null ) { - lines.add( line );//StringUtils.replace( line, "#ArtifactRepositoryPath#", mavenRepo.replace( '\\', '/' ) ) ); + lines.add( + line );//StringUtils.replace( line, "#ArtifactRepositoryPath#", mavenRepo.replace( '\\', '/' ) ) ); } return lines; --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]