Author: lcorneliussen
Date: Thu May 3 08:14:47 2012
New Revision: 1333351
URL: http://svn.apache.org/viewvc?rev=1333351&view=rev
Log:
[NPANDAY-468] npanday does not respect scope
o Only resolve until 'test' beforehand (this should be removed!!)
o Resolve compile before compile, resolve test before test
o Only include <= compile in compile and <= test in test
o Resolve "runtime" in packaging
o better exception when library isn't yet resolved when trying to compile
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DefaultCompiler.java
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java
incubator/npanday/trunk/plugins/application-maven-plugin/src/main/java/npanday/plugin/application/PackagePreparedPackageFoldersMojo.java
incubator/npanday/trunk/plugins/aspnet-maven-plugin/src/main/java/npanday/plugin/aspnet/AssemblePackageFilesMojo.java
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NPandayEarlyResolverMojo.java
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DefaultCompiler.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DefaultCompiler.java?rev=1333351&r1=1333350&r2=1333351&view=diff
==============================================================================
---
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DefaultCompiler.java
(original)
+++
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/compiler/impl/DefaultCompiler.java
Thu May 3 08:14:47 2012
@@ -116,6 +116,9 @@ public final class DefaultCompiler
for ( Artifact artifact : references )
{
+ if (artifact.getFile() == null){
+ throw new ExecutionException( "NPANDAY-155-001: File for "
+ artifact + " has not been resolved!" );
+ }
String path = artifact.getFile().getAbsolutePath();
if( !path.contains( ".jar" ) )
@@ -326,7 +329,7 @@ public final class DefaultCompiler
FileUtils.fileAppend(responseFilePath,
escapeCmdParams(command) + " ");
}
} catch (java.io.IOException e) {
- throw new ExecutionException( "Error while creating response file
for the commands.", e );
+ throw new ExecutionException( "NPANDAY-155-002: Error while
creating response file for the commands.", e );
}
filteredCommands.clear();
responseFilePath = "@" + responseFilePath;
Modified:
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java?rev=1333351&r1=1333350&r2=1333351&view=diff
==============================================================================
---
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java
(original)
+++
incubator/npanday/trunk/components/dotnet-executable/src/main/java/npanday/executable/impl/CompilerContextImpl.java
Thu May 3 08:14:47 2012
@@ -37,6 +37,7 @@ import npanday.registry.Repository;
import npanday.registry.RepositoryRegistry;
import npanday.vendor.Vendor;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
import org.apache.maven.model.Dependency;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.logging.LogEnabled;
@@ -231,6 +232,9 @@ public final class CompilerContextImpl
{
Artifact artifact = (Artifact) i.next();
+ if (!new ScopeArtifactFilter( isTestCompile() ? "test" : "compile"
).include( artifact ))
+ continue;
+
// TODO: use isAddedToClassPath instead? May need to annotate types
if (
!ArtifactTypeHelper.isDotnetLibrary( artifact.getType() )
@@ -240,8 +244,6 @@ public final class CompilerContextImpl
continue;
}
- // TODO: consider scope?
-
if ( !hasArtifact( artifact ) )
{
directLibraries.add( artifact );
Modified:
incubator/npanday/trunk/plugins/application-maven-plugin/src/main/java/npanday/plugin/application/PackagePreparedPackageFoldersMojo.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/application-maven-plugin/src/main/java/npanday/plugin/application/PackagePreparedPackageFoldersMojo.java?rev=1333351&r1=1333350&r2=1333351&view=diff
==============================================================================
---
incubator/npanday/trunk/plugins/application-maven-plugin/src/main/java/npanday/plugin/application/PackagePreparedPackageFoldersMojo.java
(original)
+++
incubator/npanday/trunk/plugins/application-maven-plugin/src/main/java/npanday/plugin/application/PackagePreparedPackageFoldersMojo.java
Thu May 3 08:14:47 2012
@@ -21,6 +21,9 @@ package npanday.plugin.application;
import com.google.common.collect.Lists;
import npanday.ArtifactType;
+import npanday.LocalRepositoryUtil;
+import npanday.resolver.NPandayDependencyResolution;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
@@ -69,15 +72,37 @@ public class PackagePreparedPackageFolde
private ZipArchiver archiver;
/**
+ * @component
+ */
+ private NPandayDependencyResolution dependencyResolution;
+
+ /**
+ * The location of the local Maven repository.
+ *
+ * @parameter expression="${settings.localRepository}"
+ */
+ protected File localRepository;
+
+ /**
* The directory for the created zip
*
* @parameter expression = "${outputDirectory}" default-value =
"${project.build.directory}"
*/
private File outputDirectory;
-
public void execute() throws MojoExecutionException, MojoFailureException
{
+ try
+ {
+ dependencyResolution.require( project, LocalRepositoryUtil.create(
localRepository ), "runtime" );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ throw new MojoExecutionException(
+ "NPANDAY-130-006: Could not resolve all runtime dependencies",
e
+ );
+ }
+
executeItems();
}
@@ -96,7 +121,7 @@ public class PackagePreparedPackageFolde
}
else
{
- getLog().debug( "NPANDAY-130-000: Did not find a prepared
package!" );
+ getLog().debug( "NPANDAY-130-005: Did not find a prepared
package!" );
}
return list;
Modified:
incubator/npanday/trunk/plugins/aspnet-maven-plugin/src/main/java/npanday/plugin/aspnet/AssemblePackageFilesMojo.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/aspnet-maven-plugin/src/main/java/npanday/plugin/aspnet/AssemblePackageFilesMojo.java?rev=1333351&r1=1333350&r2=1333351&view=diff
==============================================================================
---
incubator/npanday/trunk/plugins/aspnet-maven-plugin/src/main/java/npanday/plugin/aspnet/AssemblePackageFilesMojo.java
(original)
+++
incubator/npanday/trunk/plugins/aspnet-maven-plugin/src/main/java/npanday/plugin/aspnet/AssemblePackageFilesMojo.java
Thu May 3 08:14:47 2012
@@ -21,15 +21,21 @@ package npanday.plugin.aspnet;
import com.google.common.base.Objects;
import com.google.common.base.Splitter;
+import npanday.LocalRepositoryUtil;
import npanday.packaging.DirectoryPackagePreparer;
import npanday.packaging.MixinAsssemblyReader;
import npanday.packaging.PackagePreparationConfigurationSource;
+import npanday.resolver.NPandayDependencyResolution;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
import org.apache.maven.shared.filtering.MavenFileFilter;
+import java.io.File;
+
import static com.google.common.base.Strings.isNullOrEmpty;
import static com.google.common.collect.Iterables.toArray;
@@ -100,8 +106,27 @@ public class AssemblePackageFilesMojo
*/
private MixinAsssemblyReader assemblyReader;
+ /**
+ * The maven project.
+ *
+ * @parameter expression="${project}"
+ * @required
+ */
+ protected MavenProject project;
-/**
+ /**
+ * @component
+ */
+ private NPandayDependencyResolution dependencyResolution;
+
+ /**
+ * The location of the local Maven repository.
+ *
+ * @parameter expression="${settings.localRepository}"
+ */
+ protected File localRepository;
+
+ /**
* @component
*/
private DirectoryPackagePreparer packagePreparer;
@@ -112,6 +137,18 @@ public class AssemblePackageFilesMojo
{
long startTime = System.currentTimeMillis();
+ try
+ {
+ dependencyResolution.require( project, LocalRepositoryUtil.create(
localRepository ), "runtime" );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ throw new MojoExecutionException(
+ "NPANDAY-130-006: Could not resolve all runtime dependencies",
e
+ );
+ }
+
+
setupParameters();
final PackagePreparationConfigurationSource packageConfig =
Modified:
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java?rev=1333351&r1=1333350&r2=1333351&view=diff
==============================================================================
---
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
(original)
+++
incubator/npanday/trunk/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AbstractCompilerMojo.java
Thu May 3 08:14:47 2012
@@ -21,6 +21,7 @@ package npanday.plugin.compile;
import npanday.ArtifactType;
import npanday.ArtifactTypeHelper;
+import npanday.LocalRepositoryUtil;
import npanday.PathUtil;
import npanday.PlatformUnsupportedException;
import npanday.assembler.AssemblerContext;
@@ -33,8 +34,10 @@ import npanday.executable.compiler.Compi
import npanday.executable.compiler.CompilerExecutable;
import npanday.executable.compiler.CompilerRequirement;
import npanday.registry.RepositoryRegistry;
+import npanday.resolver.NPandayDependencyResolution;
import npanday.vendor.SettingsUtil;
import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
@@ -107,6 +110,11 @@ public abstract class AbstractCompilerMo
protected MavenProjectHelper projectHelper;
/**
+ * @component
+ */
+ private NPandayDependencyResolution dependencyResolution;
+
+ /**
* The location of the local Maven repository.
*
* @parameter expression="${settings.localRepository}"
@@ -1100,6 +1108,18 @@ public abstract class AbstractCompilerMo
{
long startTime = System.currentTimeMillis();
+ String scope = test ? "test" : "compile";
+ try
+ {
+ dependencyResolution.require( project, LocalRepositoryUtil.create(
localRepository ), scope );
+ }
+ catch ( ArtifactResolutionException e )
+ {
+ throw new MojoExecutionException(
+ "NPANDAY-900-010: Could not satisfy required dependencies for
scope " + scope, e
+ );
+ }
+
//Modifies the AssemblyInfo.cs files to match the version of the pom
try
{
Modified:
incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NPandayEarlyResolverMojo.java
URL:
http://svn.apache.org/viewvc/incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NPandayEarlyResolverMojo.java?rev=1333351&r1=1333350&r2=1333351&view=diff
==============================================================================
---
incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NPandayEarlyResolverMojo.java
(original)
+++
incubator/npanday/trunk/plugins/maven-resolver-plugin/src/main/java/npanday/plugin/resolver/NPandayEarlyResolverMojo.java
Thu May 3 08:14:47 2012
@@ -81,7 +81,7 @@ public class NPandayEarlyResolverMojo
private File localRepository;
/**
- * @parameter default-value="compile"
+ * @parameter default-value="test"
*/
private String requiredScope;
@@ -106,7 +106,7 @@ public class NPandayEarlyResolverMojo
SettingsUtil.applyCustomSettingsIfAvailable( getLog(),
repositoryRegistry, settingsPath );
getLog().warn(
- "NPANDAY-149-002: Mojo for resolving dependencies is executed! It
should only be run, "
+ "NPANDAY-149-002: Mojo for resolving dependencies beforehand is
executed! It should only be run, "
+ "if native maven plugins require special dependencies to be
resolved!"
);