[NPANDAY-622] remove pre-initialization of AssemblyContext
easier to pass the project in when needed
git-svn-id: https://svn.apache.org/repos/asf/incubator/npanday/trunk@1609037 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/components/dotnet-assembler/src/main/java/npanday/assembler/AssemblerContext.java b/components/dotnet-assembler/src/main/java/npanday/assembler/AssemblerContext.java
index caba84c..df1a3ba 100644
--- a/components/dotnet-assembler/src/main/java/npanday/assembler/AssemblerContext.java
+++ b/components/dotnet-assembler/src/main/java/npanday/assembler/AssemblerContext.java
@@ -19,7 +19,6 @@
* under the License.
*/
-import npanday.InitializationException;
import npanday.PlatformUnsupportedException;
import org.apache.maven.project.MavenProject;
@@ -41,7 +40,7 @@
*
* @return the assembly info associated with this context.
*/
- AssemblyInfo getAssemblyInfo();
+ AssemblyInfo getAssemblyInfo( MavenProject mavenProject );
/**
* Returns the marshaller for the given language
@@ -60,13 +59,4 @@
* @throws PlatformUnsupportedException the language is not supported
*/
String getClassExtensionFor( String language ) throws PlatformUnsupportedException;
-
- /**
- * Initializes the context
- *
- * @param mavenProject the maven project
- * @throws InitializationException if the context cannot be initialized
- */
- void init( MavenProject mavenProject ) throws InitializationException;
-
}
diff --git a/components/dotnet-assembler/src/main/java/npanday/assembler/impl/AssemblerContextImpl.java b/components/dotnet-assembler/src/main/java/npanday/assembler/impl/AssemblerContextImpl.java
index ccff69d..ba55b38 100644
--- a/components/dotnet-assembler/src/main/java/npanday/assembler/impl/AssemblerContextImpl.java
+++ b/components/dotnet-assembler/src/main/java/npanday/assembler/impl/AssemblerContextImpl.java
@@ -23,12 +23,13 @@
import npanday.assembler.AssemblyInfo;
import npanday.assembler.AssemblyInfoMarshaller;
import npanday.assembler.AssemblyInfoException;
-import npanday.InitializationException;
import npanday.PlatformUnsupportedException;
import npanday.model.assembly.plugins.AssemblyPlugin;
import org.apache.maven.project.MavenProject;
import org.apache.maven.model.Organization;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.logging.LogEnabled;
import org.codehaus.plexus.logging.Logger;
@@ -45,7 +46,7 @@
* role="npanday.assembler.AssemblerContext"
*/
public final class AssemblerContextImpl
- implements AssemblerContext, LogEnabled
+ implements AssemblerContext, LogEnabled, Initializable
{
private static final String SNAPSHOT_SUFFIX = "SNAPSHOT";
@@ -58,11 +59,6 @@
private RepositoryRegistry repositoryRegistry;
/**
- * The maven project
- */
- private MavenProject mavenProject;
-
- /**
* A logger for writing log messages
*/
private Logger logger;
@@ -88,10 +84,7 @@
this.logger = logger;
}
- /**
- * @see npanday.assembler.AssemblerContext#getAssemblyInfo()
- */
- public AssemblyInfo getAssemblyInfo()
+ public AssemblyInfo getAssemblyInfo( MavenProject mavenProject )
{
String basedir = mavenProject.getBasedir().toString();
AssemblyInfo assemblyInfo = new AssemblyInfo();
@@ -196,13 +189,7 @@
}
}
- /**
- * @see AssemblerContext#init(org.apache.maven.project.MavenProject)
- */
- public void init( MavenProject mavenProject )
- throws InitializationException
- {
- this.mavenProject = mavenProject;
+ public void initialize() throws InitializationException {
repository = (AssemblyPluginsRepository) repositoryRegistry.find( "assembly-plugins" );
if ( repository == null )
{
diff --git a/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AssemblyInfoGeneratorMojo.java b/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AssemblyInfoGeneratorMojo.java
index bb6087c..12c7049 100644
--- a/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AssemblyInfoGeneratorMojo.java
+++ b/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/AssemblyInfoGeneratorMojo.java
@@ -180,7 +180,7 @@
//managed by the framework. I intended to keep vendor info and state machine processor out of the
// Mojos. Unable to do so for this case. Look at new API.
VendorRequirement vendorRequirement = new VendorRequirement(vendor, vendorVersion, frameworkVersion);
- AssemblyInfo assemblyInfo = assemblerContext.getAssemblyInfo();
+ AssemblyInfo assemblyInfo = assemblerContext.getAssemblyInfo( project );
assemblyInfo.setCustomStringAttributes(this.assemblyInfo);
VendorInfo vendorInfo;
diff --git a/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/ComponentInitializerMojo.java b/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/ComponentInitializerMojo.java
index 7d01e9e..db24369 100644
--- a/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/ComponentInitializerMojo.java
+++ b/plugins/maven-compile-plugin/src/main/java/npanday/plugin/compile/ComponentInitializerMojo.java
@@ -19,13 +19,9 @@
* under the License.
*/
-import npanday.InitializationException;
import npanday.LocalRepositoryUtil;
-import npanday.assembler.AssemblerContext;
import npanday.resolver.NPandayDependencyResolution;
-import npanday.resolver.filter.DotnetAssemblyArtifactFilter;
import npanday.resolver.filter.DotnetSymbolsArtifactFilter;
-import npanday.resolver.filter.OrArtifactFilter;
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
import org.apache.maven.artifact.resolver.filter.AndArtifactFilter;
import org.apache.maven.artifact.resolver.filter.InversionArtifactFilter;
@@ -68,11 +64,6 @@
/**
* @component
*/
- private AssemblerContext assemblerContext;
-
- /**
- * @component
- */
private NPandayDependencyResolution dependencyResolution;
public void execute()
@@ -94,16 +85,5 @@
"NPANDAY-901-003: Could not satisfy required dependencies for scope " + "test", e
);
}
-
- try
- {
- assemblerContext.init( project );
- }
- catch ( InitializationException e )
- {
- throw new MojoExecutionException( "NPANDAY-901-002: Failed to initialize the assembler context", e );
- }
-
- long endTime = System.currentTimeMillis();
}
}