Author: brett Date: Tue Sep 30 11:21:28 2008 New Revision: 700539 URL: http://svn.apache.org/viewvc?rev=700539&view=rev Log: - make sure assemblies are copied with the right name for nunit tests - add utility for adjusting the path in the local repository if needed
Added: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetArtifactLocator.java (with props) incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetArtifactLocatorImpl.java (with props) incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/MavenITNUnit24Features.java (with props) incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/pom.xml (with props) incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/src/ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/src/test/ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/src/test/dotnet/ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/src/test/dotnet/AppTest.cs incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit24/ - copied from r700374, incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/MavenITmng-0007-CSharpCompileTestLibrary/ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit24/src/test/dotnet/AppTest.cs Removed: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/resource/ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit24/src/main/ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit24/src/test/dotnet/It0007.cs Modified: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerConfig.java incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerConfig.java incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerContext.java incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/NetCompilerConfigTest.java incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-core/src/main/java/org/apache/maven/dotnet/CommandExecutor.java incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/IntegrationTestSuite.java incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/MavenITmng0019BuildFailureOnNUnitFailure.java incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/MavenITmng-0020-ShareTestSource/A/pom.xml incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit24/pom.xml incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/resources/META-INF/plexus/components.xml Modified: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerConfig.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerConfig.java?rev=700539&r1=700538&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerConfig.java (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/CompilerConfig.java Tue Sep 30 11:21:28 2008 @@ -18,6 +18,7 @@ */ package org.apache.maven.dotnet.compiler; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.dotnet.ProgrammingLanguage; import org.apache.maven.dotnet.Vendor; import org.apache.maven.dotnet.ArtifactType; @@ -44,6 +45,13 @@ boolean isTestCompile(); /** + * Returns local repository + * + * @return local repository + */ + ArtifactRepository getLocalRepository(); + + /** * Sets the artifact type for the compiler plugin: library, module, exe, winexe or nar * * @param artifactType the artifact type for the compiler plugin: library, module, exe, winexe or nar @@ -57,6 +65,13 @@ */ void setTestCompile( boolean testCompile ); + /** + * Sets local repository + * + * @param localRepository + */ + void setLocalRepository( ArtifactRepository localRepository ); + void setCompilerSourceDirectory( File sourceDirectory ); /** Added: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetArtifactLocator.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetArtifactLocator.java?rev=700539&view=auto ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetArtifactLocator.java (added) +++ incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetArtifactLocator.java Tue Sep 30 11:21:28 2008 @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.dotnet.compiler; + +import java.io.File; +import java.io.IOException; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; + +/** + * Assist in locating an artifact, including creating a shadow copy in the local repository or target workspace to + * ensure that the assembly filename is uncompromised for the linker. + * + * This should be made redundant by changes to the Maven core to support this within the local repository. + */ +public interface DotnetArtifactLocator +{ + /** + * Get the correct file name for an assembly. A shadow copy will never be created. + * @param artifact the assembly artifact to determine the correct file name for + * @param localRepository the local repository to search in + * @return the file name + */ + String getAssemblyFileName( Artifact artifact, ArtifactRepository localRepository ); + + /** + * Get a copy of the artifact from the local repository, with the correct file name for an assembly. + * A shadow copy will be created if needed. + * @param artifact the assembly artifact to determine the correct file name for + * @param localRepository the local repository to search in + * @return the file in the local repository + */ + File getArtifactFromLocalRepository( Artifact artifact, ArtifactRepository localRepository ); +} Propchange: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetArtifactLocator.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetArtifactLocator.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerConfig.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerConfig.java?rev=700539&r1=700538&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerConfig.java (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerConfig.java Tue Sep 30 11:21:28 2008 @@ -18,13 +18,14 @@ */ package org.apache.maven.dotnet.compiler; +import java.io.File; + +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.dotnet.ArtifactType; import org.apache.maven.dotnet.ProgrammingLanguage; import org.apache.maven.dotnet.Vendor; -import org.apache.maven.dotnet.ArtifactType; import org.apache.maven.toolchain.Toolchain; -import java.io.File; - public interface DotnetCompilerConfig extends CompilerConfig { @@ -73,6 +74,8 @@ private boolean isTestCompile; + private ArtifactRepository localRepository; + private File compileSourceDirectory; private File targetDirectory; @@ -145,6 +148,16 @@ isTestCompile = testCompile; } + public ArtifactRepository getLocalRepository() + { + return localRepository; + } + + public void setLocalRepository( ArtifactRepository localRepository ) + { + this.localRepository = localRepository; + } + public File getCompilerDirectory() { return compileSourceDirectory; @@ -198,6 +211,11 @@ throw new IllegalArgumentException( "compilerPlatformVersion" ); } + if ( localRepository == null || localRepository.getUrl() == null ) + { + throw new IllegalArgumentException( "localRepository" ); + } + if ( compileSourceDirectory == null) { throw new IllegalArgumentException( "sourceDirectory" ); @@ -248,6 +266,10 @@ { return false; } + if ( !localRepository.equals( that.getLocalRepository() ) ) + { + return false; + } if ( programmingLanguage != that.getProgrammingLanguage() ) { return false; @@ -275,6 +297,7 @@ result = 29 * result + compilerPlatformVersion.hashCode(); result = 29 * result + artifactType.hashCode(); result = 29 * result + ( isTestCompile ? 1 : 0 ); + result = 29 * result + localRepository.hashCode(); result = 29 * result + compileSourceDirectory.hashCode(); result = 29 * result + targetDirectory.hashCode(); result = 29 * result + programmingLanguage.hashCode(); Modified: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerContext.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerContext.java?rev=700539&r1=700538&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerContext.java (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/DotnetCompilerContext.java Tue Sep 30 11:21:28 2008 @@ -85,4 +85,10 @@ */ Set<File> getWin32Resources(); + /** + * The artifact locator, responsible for creating shadow copies of artifacts if needed. + * @return artifact locator + */ + DotnetArtifactLocator getArtifactLocator(); + } Added: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetArtifactLocatorImpl.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetArtifactLocatorImpl.java?rev=700539&view=auto ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetArtifactLocatorImpl.java (added) +++ incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetArtifactLocatorImpl.java Tue Sep 30 11:21:28 2008 @@ -0,0 +1,104 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.dotnet.compiler.impl; + +import java.io.File; +import java.io.IOException; +import java.util.Collections; +import java.util.logging.Logger; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.dotnet.compiler.DotnetArtifactLocator; +import org.apache.maven.model.Build; +import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectBuilder; +import org.apache.maven.project.ProjectBuildingException; +import org.codehaus.plexus.util.FileUtils; + +/** + * Default implementation of the [EMAIL PROTECTED] DotnetArtifactLocator}. Note that the implementation reads metadata from the + * local repository to confirm the final name as it is not stored during the resolution process. This makes these calls + * inefficient to make repetitively. + */ +public final class DotnetArtifactLocatorImpl + implements DotnetArtifactLocator +{ + private MavenProjectBuilder projectBuilder; + + // TODO: plexus logger? + private Logger logger = Logger.getAnonymousLogger(); + + public String getAssemblyFileName( Artifact artifact, ArtifactRepository localRepository ) + { + String finalName = artifact.getFile().getName(); + try + { + MavenProject project = + projectBuilder.buildFromRepository( artifact, Collections.EMPTY_LIST, localRepository ); + Build build = project.getBuild(); + if ( build != null && build.getFinalName() != null ) + { + // XXX: 2.1.0-M1 doesn't interpolate this properly, workaround + if ( build.getFinalName().indexOf( "${" ) < 0 ) + { + finalName = build.getFinalName() + "." + artifact.getArtifactHandler().getExtension(); + logger.fine( "Using alternate final name for artifact: '" + artifact + "' = '" + finalName + "'" ); + } + } + } + catch ( ProjectBuildingException e ) + { + logger.info( "Error reading project from the local repository, using default assembly filename (" + + e.getMessage() + ")" ); + } + return finalName; + } + + public File getArtifactFromLocalRepository( Artifact artifact, ArtifactRepository localRepository ) + { + String finalName = getAssemblyFileName( artifact, localRepository ); + + if ( !finalName.equals( artifact.getFile().getName() ) ) + { + // adjust to a subdirectory for the version + File file = new File( localRepository.getBasedir(), localRepository.pathOf( artifact ) ).getParentFile(); + file = new File( file, artifact.getVersion() ); + file.mkdirs(); + file = new File( file, finalName ); + + // make a copy of the file if it doesn't exist + if ( !file.exists() ) + { + try + { + FileUtils.copyFile( artifact.getFile(), file ); + } + catch ( IOException e ) + { + logger.info( "Error copy file in the local repository, using original (" + e.getMessage() + ")" ); + } + } + + artifact.setFile( file ); + } + + return artifact.getFile(); + } +} Propchange: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetArtifactLocatorImpl.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetArtifactLocatorImpl.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java?rev=700539&r1=700538&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/main/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImpl.java Tue Sep 30 11:21:28 2008 @@ -34,6 +34,7 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.dotnet.compiler.ClassCompiler; import org.apache.maven.dotnet.compiler.CompilerConfig; +import org.apache.maven.dotnet.compiler.DotnetArtifactLocator; import org.apache.maven.dotnet.compiler.DotnetCompilerConfig; import org.apache.maven.dotnet.compiler.DotnetCompilerContext; import org.apache.maven.dotnet.InitializationException; @@ -84,6 +85,8 @@ private Toolchain toolchain; + private DotnetArtifactLocator artifactLocator; + public Set<String> getCoreAssemblyNames() { return null; @@ -413,4 +416,9 @@ { return value.replaceAll( "[/\\\\]+", "\\" + File.separator ); } + + public DotnetArtifactLocator getArtifactLocator() + { + return artifactLocator; + } } Modified: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/NetCompilerConfigTest.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/NetCompilerConfigTest.java?rev=700539&r1=700538&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/NetCompilerConfigTest.java (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/NetCompilerConfigTest.java Tue Sep 30 11:21:28 2008 @@ -18,12 +18,16 @@ */ package org.apache.maven.dotnet.compiler; +import org.junit.Assert; import org.junit.Test; +import org.apache.maven.artifact.repository.DefaultArtifactRepository; +import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.dotnet.ProgrammingLanguage; import org.apache.maven.dotnet.Vendor; import org.apache.maven.dotnet.ArtifactType; import java.io.File; +import java.net.MalformedURLException; public class NetCompilerConfigTest { @@ -55,6 +59,16 @@ } @Test(expected = IllegalArgumentException.class) + public void verifyCompilerConfig_WithNullLocalRepository() + throws IllegalArgumentException + { + DotnetCompilerConfig config = getDefaultDotnetCompilerConfig(); + config.setLocalRepository( null); + + config.verifyCompilerConfig(); + } + + @Test(expected = IllegalArgumentException.class) public void verifyCompilerConfig_WithNullProgrammingLanguage() throws IllegalArgumentException { @@ -119,6 +133,15 @@ DotnetCompilerConfig config = DotnetCompilerConfig.Factory.createDefaultCompilerConfig(); config.setArtifactType( ArtifactType.LIBRARY ); config.setCompilerPlatformVersion( DotnetCompilerPlatformVersion.VERSION_2_0_50727 ); + try + { + config.setLocalRepository( new DefaultArtifactRepository( "local", new File( "." ).toURL().toExternalForm(), + new DefaultRepositoryLayout() ) ); + } + catch ( MalformedURLException e ) + { + Assert.fail( e.getMessage() ); + } config.setProgrammingLanguage( ProgrammingLanguage.C_SHARP ); config.setCompilerSourceDirectory( new File( "." ) ); config.setTargetDirectory( new File( "." ) ); Modified: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java?rev=700539&r1=700538&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-compiler/src/test/java/org/apache/maven/dotnet/compiler/impl/DotnetCompilerContextImplTest.java Tue Sep 30 11:21:28 2008 @@ -18,32 +18,34 @@ */ package org.apache.maven.dotnet.compiler.impl; -import java.util.HashSet; -import java.util.Set; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.junit.Assert.assertThat; + import java.io.File; import java.io.IOException; +import java.net.MalformedURLException; +import java.util.HashSet; +import java.util.Set; -import org.apache.maven.project.MavenProject; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.DefaultArtifact; import org.apache.maven.artifact.handler.DefaultArtifactHandler; +import org.apache.maven.artifact.repository.DefaultArtifactRepository; +import org.apache.maven.artifact.repository.layout.DefaultRepositoryLayout; import org.apache.maven.artifact.versioning.VersionRange; -import org.apache.maven.model.Build; - -import org.apache.maven.dotnet.compiler.DotnetCompilerConfig; +import org.apache.maven.dotnet.ArtifactScope; import org.apache.maven.dotnet.ArtifactType; -import org.apache.maven.dotnet.compiler.DotnetCompilerPlatformVersion; +import org.apache.maven.dotnet.InitializationException; import org.apache.maven.dotnet.ProgrammingLanguage; import org.apache.maven.dotnet.Vendor; -import org.apache.maven.dotnet.InitializationException; -import org.apache.maven.dotnet.ArtifactScope; import org.apache.maven.dotnet.compiler.ClassCompiler; - -import org.junit.Test; -import static org.hamcrest.CoreMatchers.equalTo; +import org.apache.maven.dotnet.compiler.DotnetCompilerConfig; +import org.apache.maven.dotnet.compiler.DotnetCompilerPlatformVersion; +import org.apache.maven.model.Build; +import org.apache.maven.project.MavenProject; import org.hamcrest.BaseMatcher; import org.hamcrest.CoreMatchers; -import static org.junit.Assert.*; +import org.junit.Test; public class DotnetCompilerContextImplTest { @@ -325,11 +327,13 @@ ClassCompiler compiler = ctx.getClassCompiler(); } - private static DotnetCompilerConfig getDefaultDotnetCompilerConfig() + private static DotnetCompilerConfig getDefaultDotnetCompilerConfig() throws MalformedURLException { DotnetCompilerConfig config = DotnetCompilerConfig.Factory.createDefaultCompilerConfig(); config.setArtifactType( ArtifactType.LIBRARY ); config.setCompilerPlatformVersion( DotnetCompilerPlatformVersion.VERSION_2_0_50727 ); + config.setLocalRepository( new DefaultArtifactRepository( "local", new File( "." ).toURL().toExternalForm(), + new DefaultRepositoryLayout() ) ); config.setProgrammingLanguage( ProgrammingLanguage.C_SHARP ); config.setCompilerSourceDirectory( new File( "." ) ); config.setTargetDirectory( new File( "." ) ); Modified: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-core/src/main/java/org/apache/maven/dotnet/CommandExecutor.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-core/src/main/java/org/apache/maven/dotnet/CommandExecutor.java?rev=700539&r1=700538&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-core/src/main/java/org/apache/maven/dotnet/CommandExecutor.java (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-core/src/main/java/org/apache/maven/dotnet/CommandExecutor.java Tue Sep 30 11:21:28 2008 @@ -18,17 +18,17 @@ */ package org.apache.maven.dotnet; +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; + import org.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.util.cli.StreamConsumer; -import org.codehaus.plexus.util.cli.Commandline; -import org.codehaus.plexus.util.cli.CommandLineUtils; 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 java.util.List; -import java.util.ArrayList; -import java.util.logging.Level; -import java.io.File; +import org.codehaus.plexus.util.cli.StreamConsumer; /** * Provides services for executing commands such as compilers or executables. A <code>ClassCompiler</code> implementation can use the Modified: incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java?rev=700539&r1=700538&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/components/maven-dotnet-extensions/src/main/java/org/apache/maven/dotnet/extensions/compiler/CSharpClassCompiler.java Tue Sep 30 11:21:28 2008 @@ -96,8 +96,10 @@ { for ( Artifact artifact : references ) { - String path = artifact.getFile().getAbsolutePath(); - commands.add( "/reference:" + path ); + // It isn't necessary to rename the file for compilation, even if it was compiled with a different one, + // so use it straight from the repository + File file = artifact.getFile(); + commands.add( "/reference:" + file.getAbsolutePath() ); } } Modified: incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/IntegrationTestSuite.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/IntegrationTestSuite.java?rev=700539&r1=700538&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/IntegrationTestSuite.java (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/IntegrationTestSuite.java Tue Sep 30 11:21:28 2008 @@ -29,27 +29,25 @@ { TestSuite suite = new TestSuite(); - // NMAVEN-8 - //suite.addTestSuite( MavenITmng0007CSharpCompileTestLibrary.class ); - //suite.addTestSuite( MavenITmng0019BuildFailureOnNUnitFailure.class ); - //suite.addTestSuite( MavenITmng0020ShareTestSource.class ); - // Fails occasionally with: // error CS1548: Cryptographic failure while signing assembly ... The process cannot access the file because it is being used by another process. ' // suite.addTestSuite( MavenITmng0017CSharpStrongNamedAssembly.class ); - // Neeed to be able to locate the GAC root, perhaps using the toolchain + // Need to be able to locate the GAC root, perhaps using the toolchain // suite.addTestSuite( MavenITmng0009CSharpCompileWithProvidedGacDependency.class ); // Currently requiring library in $M2_HOME/lib when extension should be enough // suite.addTestSuite( MavenITDotNetToolchain.class ); + suite.addTestSuite( MavenITNUnit24Features.class ); + suite.addTestSuite( MavenITmng0000CSharpCompileLibrary.class ); suite.addTestSuite( MavenITmng0001CSharpCompileExe.class ); suite.addTestSuite( MavenITmng0002CSharpCompileModule.class ); suite.addTestSuite( MavenITmng0003CSharpCompileWinexe.class ); suite.addTestSuite( MavenITmng0004CSharpCompileWithDependency.class ); suite.addTestSuite( MavenITmng0005CSharpCompileWithTransitiveDependency.class ); + suite.addTestSuite( MavenITmng0007CSharpCompileTestLibrary.class ); suite.addTestSuite( MavenITmng0008CSharpCompileWithProvidedDependency.class ); suite.addTestSuite( MavenITmng0010DeployLibrary.class ); suite.addTestSuite( MavenITmng0011DeployExe.class ); @@ -59,6 +57,11 @@ suite.addTestSuite( MavenITmng0015DeployLibraryAsSnapshot.class ); suite.addTestSuite( MavenITmng0016CSharpAssemblyInfoGeneration.class ); suite.addTestSuite( MavenITmng0018CSharpSynchronizeTargetWithSource.class ); + suite.addTestSuite( MavenITmng0019BuildFailureOnNUnitFailure.class ); + + // Looks to link to NMaven.Its.It0020B-1.0.0-test 0.0.0.0 instead of the correct version + //suite.addTestSuite( MavenITmng0020ShareTestSource.class ); + return suite; } } Added: incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/MavenITNUnit24Features.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/MavenITNUnit24Features.java?rev=700539&view=auto ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/MavenITNUnit24Features.java (added) +++ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/MavenITNUnit24Features.java Tue Sep 30 11:21:28 2008 @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.dotnet.integrationtests; + +import java.io.File; + +import org.apache.maven.it.VerificationException; +import org.apache.maven.it.Verifier; + +public class MavenITNUnit24Features + extends AbstractNMavenIntegrationTestCase +{ + public void testNUnit24Features() + throws Exception + { + File testDir = extractAndTranslateResources( "/NUnit24Features/NUnit24" ); + Verifier verifier = getVerifier( testDir ); + verifier.executeGoal( "install" ); + verifier.assertFilePresent( getAssemblyFile( "NMaven.It.NUnit24FeaturesNUnit24", "1.0.0", "dll", "test" ) ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + testDir = extractAndTranslateResources( "/NUnit24Features/NUnit22" ); + verifier = getVerifier( testDir ); + try + { + verifier.executeGoal( "install" ); + fail( "Should have thrown an exception" ); + } + catch ( VerificationException e ) + { + // expected + } + verifier.resetStreams(); + } +} Propchange: incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/MavenITNUnit24Features.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/MavenITNUnit24Features.java ------------------------------------------------------------------------------ svn:mime-type = text/plain Modified: incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/MavenITmng0019BuildFailureOnNUnitFailure.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/MavenITmng0019BuildFailureOnNUnitFailure.java?rev=700539&r1=700538&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/MavenITmng0019BuildFailureOnNUnitFailure.java (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/java/org/apache/maven/dotnet/integrationtests/MavenITmng0019BuildFailureOnNUnitFailure.java Tue Sep 30 11:21:28 2008 @@ -31,11 +31,10 @@ { File testDir = extractAndTranslateResources( "/MavenITmng-0019-BuildFailureOnNUnitFailure" ); Verifier verifier = getVerifier( testDir ); - verifier.executeGoal( "test" ); try { - verifier.verifyErrorFreeLog(); + verifier.executeGoal( "test" ); fail( "Log has no errors, expected test failure" ); } catch ( VerificationException e ) Modified: incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/MavenITmng-0020-ShareTestSource/A/pom.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/MavenITmng-0020-ShareTestSource/A/pom.xml?rev=700539&r1=700538&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/MavenITmng-0020-ShareTestSource/A/pom.xml (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/MavenITmng-0020-ShareTestSource/A/pom.xml Tue Sep 30 11:21:28 2008 @@ -57,9 +57,9 @@ </build> <dependencies> <dependency> - <groupId>org.apache.maven.dotnet</groupId> + <groupId>NUnit</groupId> <artifactId>NUnit.Framework</artifactId> - <version>2.4.8.0</version> + <version>2.2.8.0</version> <type>dotnet:library</type> <scope>test</scope> </dependency> @@ -68,6 +68,7 @@ <groupId>NMaven.Its</groupId> <artifactId>NMaven.It.It0020B</artifactId> <scope>test</scope> + <classifier>test</classifier> <version>1.0.0</version> <type>dotnet:library</type> </dependency> Added: incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/pom.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/pom.xml?rev=700539&view=auto ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/pom.xml (added) +++ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/pom.xml Tue Sep 30 11:21:28 2008 @@ -0,0 +1,61 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you 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. +--> +<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>NMaven.Its</groupId> + <artifactId>NMaven.It.NUnit24FeaturesNUnit22</artifactId> + <packaging>dotnet:library</packaging> + <version>1.0.0</version> + + <build> + <sourceDirectory>src/main/dotnet</sourceDirectory> + <testSourceDirectory>src/test/dotnet</testSourceDirectory> + <plugins> + <plugin> + <groupId>org.apache.maven.dotnet.plugins</groupId> + <artifactId>maven-dotnet-compiler-plugin</artifactId> + <version>${nmaven.version}</version> + <extensions>true</extensions> + </plugin> + <plugin> + <groupId>org.apache.maven.dotnet.plugins</groupId> + <artifactId>maven-dotnet-test-plugin</artifactId> + <version>${nmaven.version}</version> + <configuration> + <arguments> + <param>/nologo</param> + <param>/labels</param> + </arguments> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>NUnit</groupId> + <artifactId>NUnit.Framework</artifactId> + <version>2.2.8.0</version> + <type>dotnet:library</type> + <scope>test</scope> + </dependency> + </dependencies> +</project> Propchange: incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/src/test/dotnet/AppTest.cs URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/src/test/dotnet/AppTest.cs?rev=700539&view=auto ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/src/test/dotnet/AppTest.cs (added) +++ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit22/src/test/dotnet/AppTest.cs Tue Sep 30 11:21:28 2008 @@ -0,0 +1,36 @@ +#region Apache License, Version 2.0 +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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. +// +#endregion +using System; +using NUnit.Framework; +using NUnit.Framework.Constraints; +using NUnit.Framework.SyntaxHelpers; + +namespace NMaven.IT { + + [TestFixture] + public class AppTest { + [Test] + public void testSimple1() { + Assert.That( "Hello", Is.EqualTo("Hello") ); + } + + } +} Modified: incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit24/pom.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit24/pom.xml?rev=700539&r1=700374&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit24/pom.xml (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit24/pom.xml Tue Sep 30 11:21:28 2008 @@ -22,10 +22,9 @@ 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>NMaven.Its</groupId> - <artifactId>NMaven.It.It0007</artifactId> + <artifactId>NMaven.It.NUnit24FeaturesNUnit24</artifactId> <packaging>dotnet:library</packaging> <version>1.0.0</version> - <name>NMaven.It.It0007</name> <build> <sourceDirectory>src/main/dotnet</sourceDirectory> @@ -54,7 +53,7 @@ <dependency> <groupId>NUnit</groupId> <artifactId>NUnit.Framework</artifactId> - <version>2.2.8.0</version> + <version>2.4.8.0</version> <type>dotnet:library</type> <scope>test</scope> </dependency> Added: incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit24/src/test/dotnet/AppTest.cs URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit24/src/test/dotnet/AppTest.cs?rev=700539&view=auto ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit24/src/test/dotnet/AppTest.cs (added) +++ incubator/nmaven/branches/NMAVEN-8-nunit/core-integration-tests/src/test/resources/NUnit24Features/NUnit24/src/test/dotnet/AppTest.cs Tue Sep 30 11:21:28 2008 @@ -0,0 +1,36 @@ +#region Apache License, Version 2.0 +// +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you 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. +// +#endregion +using System; +using NUnit.Framework; +using NUnit.Framework.Constraints; +using NUnit.Framework.SyntaxHelpers; + +namespace NMaven.IT { + + [TestFixture] + public class AppTest { + [Test] + public void testSimple1() { + Assert.That( "Hello", Is.EqualTo("Hello") ); + } + + } +} Modified: incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java?rev=700539&r1=700538&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/CompilerMojo.java Tue Sep 30 11:21:28 2008 @@ -21,6 +21,7 @@ import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.dotnet.compiler.DotnetCompilerContext; import org.apache.maven.dotnet.compiler.DotnetCompilerConfig; import org.apache.maven.dotnet.compiler.DotnetCompilerPlatformVersion; @@ -59,6 +60,14 @@ private MavenProject project; /** + * The location of the local Maven repository. + * + * @parameter expression="${localRepository}" + * @readonly + */ + private ArtifactRepository localRepository; + + /** * Specify a strong name key file. * * @parameter expression = "${keyfile}" @@ -162,6 +171,7 @@ keyInfo.setKeyContainerName( keycontainer ); compilerConfig.setKeyInfo( keyInfo ); + compilerConfig.setLocalRepository( localRepository ); compilerConfig.setProgrammingLanguage( ProgrammingLanguage.C_SHARP ); compilerConfig.setCompilerSourceDirectory( sourceDir ); compilerConfig.setVendor( vendor ); Modified: incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java?rev=700539&r1=700538&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/java/org/apache/maven/dotnet/plugin/compiler/TestCompilerMojo.java Tue Sep 30 11:21:28 2008 @@ -28,6 +28,7 @@ import org.apache.maven.dotnet.ProgrammingLanguage; import org.apache.maven.dotnet.Vendor; import org.apache.maven.dotnet.ArtifactScope; +import org.apache.maven.dotnet.compiler.DotnetArtifactLocator; import org.apache.maven.dotnet.compiler.DotnetCompilerConfig; import org.apache.maven.dotnet.compiler.DotnetCompilerContext; import org.apache.maven.dotnet.compiler.DotnetCompilerPlatformVersion; @@ -36,7 +37,10 @@ import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.MavenProjectHelper; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.metadata.ArtifactMetadataSource; +import org.apache.maven.artifact.repository.ArtifactRepository; import org.codehaus.plexus.util.FileUtils; /** @@ -85,6 +89,21 @@ */ private DotnetCompilerContext compilerContext; + /** + * @component + */ + private DotnetArtifactLocator artifactLocator; + + /** + * @parameter expression="${localRepository}" + * @readonly + */ + private ArtifactRepository localRepository; + + /** + * @component + */ + private MavenProjectHelper projectHelper; public void execute() throws MojoExecutionException, MojoFailureException @@ -121,6 +140,7 @@ compilerConfig.setArtifactType( ArtifactType.LIBRARY ); compilerConfig.setCompilerPlatformVersion( DotnetCompilerPlatformVersion.valueFromVersion( frameworkVersion ) ); + compilerConfig.setLocalRepository( localRepository ); compilerConfig.setProgrammingLanguage( ProgrammingLanguage.C_SHARP ); compilerConfig.setTestCompile( true ); compilerConfig.setCompilerSourceDirectory( sourceDir ); @@ -146,6 +166,7 @@ try { testAssembly = compilerContext.getClassCompiler().compile(); + projectHelper.attachArtifact( project, "dotnet:library", "test", testAssembly ); } catch ( InvalidArtifactException e ) { @@ -161,14 +182,15 @@ throw new MojoExecutionException( "Unable to create test assemblies directory: " + testAssemblies ); } - Set<Artifact> testDependencies = compilerContext.getLibraryDependenciesFor( ArtifactScope.TEST ); + Set<Artifact> testDependencies = compilerContext.getLibraryDependenciesFor( ArtifactScope.TEST ); try { for ( Artifact testDependency : testDependencies ) { File testDependencyFile = testDependency.getFile(); - File testAssembliesFile = new File( testAssemblies, testDependencyFile.getName() ); + File testAssembliesFile = + new File( testAssemblies, artifactLocator.getAssemblyFileName( testDependency, localRepository ) ); FileUtils.copyFile( testDependencyFile, testAssembliesFile ); } Modified: incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/resources/META-INF/plexus/components.xml URL: http://svn.apache.org/viewvc/incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/resources/META-INF/plexus/components.xml?rev=700539&r1=700538&r2=700539&view=diff ============================================================================== --- incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/resources/META-INF/plexus/components.xml (original) +++ incubator/nmaven/branches/NMAVEN-8-nunit/plugins/maven-dotnet-compiler-plugin/src/main/resources/META-INF/plexus/components.xml Tue Sep 30 11:21:28 2008 @@ -288,6 +288,21 @@ <component> <role>org.apache.maven.dotnet.compiler.DotnetCompilerContext</role> <implementation>org.apache.maven.dotnet.compiler.impl.DotnetCompilerContextImpl</implementation> + <requirements> + <requirement> + <role>org.apache.maven.dotnet.compiler.DotnetArtifactLocator</role> + </requirement> + </requirements> + </component> + <component> + <role>org.apache.maven.dotnet.compiler.DotnetArtifactLocator</role> + <implementation>org.apache.maven.dotnet.compiler.impl.DotnetArtifactLocatorImpl</implementation> + <requirements> + <requirement> + <role>org.apache.maven.project.MavenProjectBuilder</role> + <fieldName>projectBuilder</fieldName> + </requirement> + </requirements> </component> <component> <role>org.apache.maven.toolchain.ToolchainFactory</role>