You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "Stevenson, Chris" <Ch...@DrKW.com> on 2005/10/28 17:20:28 UTC

[m2] Custom package dependencies (dotnet dll's) not being found f or compile step in CSharpCompiler

Dear All,
 
I've been writing a dotnet plugin for Maven to compile/NDoc/Nunit a dotnet
project within Maven 2. Things have been progressing well but I've got to
real sticking point with handling custom dependent types. 
 
What I've done is:
 
1. Use a custom compiler (written by Trygve and overs) to compile the C#
libraries.
2. Written a dotnet plugin which defines its own build process for dotnet
projects (using as much as possible of the existing build process)
 
My problem is the custom compiler is not being passed the dependencies that
I have defined in the pom (they are of a custom package dotnet-libray that I
have defined). The only entry in the "${project.compileClasspathElements}"
that is being passed to the CSharpCompiler is the path to the output
directory as a string.
 
So my questions are:
 
1. Should I/one of the existing build components set this variable by
manually adding my dlls as dependants? If I should should it be in a custom
implementation of the resources:resources goal?
2. If not is there some way I can pass this info to the custom compiler
through the POM?
 
I know that the dependency is definately being found (see output from
compile goal)
 
Any help much appreciated.

Regards, Chris.

 
Here is the POM in my CSharp project, my custom build cycle and the output
from the compile step:
 
------
POM
------

<project>
	<modelVersion>4.0.0</modelVersion>
	<artifactId>csharp-sample</artifactId>
	<groupId>engn</groupId>
	<name>Engine CSharp Test</name>
	<version>SNAPSHOT</version>
	<packaging>dotnet-exe</packaging>
	<build>
		<directory>target</directory>
		<outputDirectory>target/dotnet-assembly</outputDirectory>
	
<testOutputDirectory>target/test-dotnet-assembly</testOutputDirectory>
		<sourceDirectory>src/main/csharp</sourceDirectory>
		<testSourceDirectory>src/test/csharp</testSourceDirectory>
  		<plugins>
			<plugin>
	
<artifactId>maven-compiler-plugin</artifactId>
				<version>2.0</version>
				<configuration>
					<compilerId>csharp</compilerId>
					<fork>true</fork>
					<executable>csc</executable>
					<includes>
						<include>**/*.cs</include>
					</includes>
					<verbose>true</verbose>
					
					<compilerArguments>
	
<mainClass>ConsoleApplication1.ConsoleApp</mainClass>
						<doc>true</doc>
						<target>exe</target>
					</compilerArguments>
					
				</configuration>
	
				<extensions>true</extensions>
	
				<dependencies>
					<dependency>
	
<groupId>org.codehaus.plexus</groupId>
	
<artifactId>plexus-compiler-csharp</artifactId>
	
<version>1.6-SNAPSHOT</version>
					</dependency>
				</dependencies>
				
			</plugin>
			
			<plugin>
				<groupId>engn</groupId>
	
<artifactId>engn-maven-plugin-dotnet</artifactId>
				<extensions>true</extensions>
			</plugin>		
			
	</plugins>

	</build>

	<dependencies>
		<dependency>
			<groupId>nunit</groupId>
			<artifactId>nunit.framework</artifactId>
			<version>2.2</version>
			<type>dotnet-library</type>
		</dependency>
	</dependencies>
	
</project>


------
Custom LifeCycle
------

 
 <component-set>
  
  <components>
  
      <component>
        <role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
        <role-hint>dotnet-library</role-hint>
 
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</
implementation>
        <configuration>
          <phases>
 
<process-resources>org.apache.maven.plugins:maven-resources-plugin:resources
</process-resources>
 
<compile>org.apache.maven.plugins:maven-compiler-plugin:compile</compile>
 
<process-test-resources>org.apache.maven.plugins:maven-resources-plugin:test
Resources</process-test-resources>
 
<test-compile>org.apache.maven.plugins:maven-compiler-plugin:testCompile</te
st-compile>
            <test>engn:engn-maven-plugin-dotnet:test</test>
            <package>engn:engn-maven-plugin-dotnet:package</package>
 
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
 
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
          </phases>
        </configuration>
      </component>
 
 .... (plus more)
 

------
Compile goal output on Csharp project (sorry is a bit verbose) See
comments***
------

C:\Work\Eclipse\Workspace\trunk\sample-csharp>mvn
-Duser.home=C:\Work\SCM\CVS\CPDS\trunk\m2.user.home compile
-e -X -o
+ Error stacktraces are turned on.
[DEBUG] Building Maven user-level plugin registry from:
'C:\Work\SCM\CVS\CPDS\trunk\m2.user.home\.m2\plugin-re
gistry.xml'
[DEBUG] Building Maven global-level plugin registry from: 'C:\Program
Files\Apache Software Foundation\Maven 2
\maven-2.0\conf\plugin-registry.xml'
[INFO]
NOTE: Maven is executing in offline mode. Any artifacts not already in your
local
repository will be inaccessible.

[INFO] Scanning for projects...
[DEBUG] Retrieving parent-POM from the repository for project:
null:maven-compiler-plugin:maven-plugin:2.0
[DEBUG] engn-maven-plugin-dotnet: resolved to version 0.1 from local
repository
[INFO]
----------------------------------------------------------------------------
[INFO] Building Engine CSharp Test
[INFO]    task-segment: [compile]
[INFO]
----------------------------------------------------------------------------
[ERROR] Nonexistent component:
org.apache.maven.lifecycle.mapping.LifecycleMappingdotnet-exe

************************************** Comment
************************************** 
It seems that the below error message is a bug in mvn core as the lifecycle
is definitely found as it executes all my custom setps.
**************************************
************************************** 

[DEBUG] Unable to find the lifecycle component in the extension
org.codehaus.plexus.component.repository.exception.ComponentLookupException:
Component descriptor cannot be fo
und in the component repository:
org.apache.maven.lifecycle.mapping.LifecycleMappingdotnet-exe.
        at
org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.jav
a:319)
        at
org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.jav
a:312)
        at
org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.jav
a:436)
        at
org.apache.maven.plugin.DefaultPluginManager.getPluginComponent(DefaultPlugi
nManager.java:1185)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.findExtension(DefaultLif
ecycleExecutor.java:984
)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.findMappingsForLifecycle
(DefaultLifecycleExecut
or.java:925)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.bindLifecycleForPackagin
g(DefaultLifecycleExecu
tor.java:879)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.constructLifecycleMappin
gs(DefaultLifecycleExec
utor.java:862)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoal(DefaultLifec
ycleExecutor.java:447)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeGoalAndHandleFail
ures(DefaultLifecycleEx
ecutor.java:301)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.executeTaskSegments(Defa
ultLifecycleExecutor.ja
va:268)
        at
org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycle
Executor.java:137)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:316)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:113)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:249)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39
)
        at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl
.java:25)
        at java.lang.reflect.Method.invoke(Method.java:324)
        at
org.codehaus.classworlds.Launcher.launchEnhanced(Launcher.java:315)
        at org.codehaus.classworlds.Launcher.launch(Launcher.java:255)
        at
org.codehaus.classworlds.Launcher.mainWithExitCode(Launcher.java:430)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:375)
[DEBUG] maven-resources-plugin: resolved to version 2.1 from repository
central
[DEBUG] Retrieving parent-POM from the repository for project:
null:maven-resources-plugin:maven-plugin:2.1
[DEBUG] org.apache.maven.plugins:maven-resources-plugin:maven-plugin:2.1
(selected for runtime)
[DEBUG] Retrieving parent-POM from the repository for project:
org.apache.maven:maven-model:jar:2.0
[DEBUG]   org.apache.maven:maven-model:jar:2.0 (selected for runtime)
[DEBUG]     org.codehaus.plexus:plexus-utils:jar:1.0.4 (selected for
runtime)
[DEBUG] Retrieving parent-POM from the repository for project:
null:maven-project:jar:2.0
[DEBUG]   org.apache.maven:maven-project:jar:2.0 (selected for runtime)
[DEBUG]     org.codehaus.plexus:plexus-utils:jar:1.0.4 (selected for
runtime)
[DEBUG]     org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
(selected for runtime)
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4 (selected for
runtime)
[DEBUG]       classworlds:classworlds:jar:1.1-alpha-2 (selected for runtime)
[DEBUG]       junit:junit:jar:3.8.1 (selected for runtime)
[DEBUG] Retrieving parent-POM from the repository for project:
org.apache.maven:maven-artifact:jar:2.0
[DEBUG]     org.apache.maven:maven-artifact:jar:2.0 (selected for runtime)
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4 (selected for
runtime)
[DEBUG]     org.apache.maven:maven-model:jar:2.0 (selected for runtime)
[DEBUG] Retrieving parent-POM from the repository for project:
org.apache.maven:maven-artifact-manager:jar:2.0

[DEBUG]     org.apache.maven:maven-artifact-manager:jar:2.0 (selected for
runtime)
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4 (selected for
runtime)
[DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
(selected for runtime)
[DEBUG]       org.apache.maven:maven-artifact:jar:2.0 (selected for runtime)
[DEBUG] Retrieving parent-POM from the repository for project:
org.apache.maven:maven-repository-metadata:jar:
2.0
[DEBUG]       org.apache.maven:maven-repository-metadata:jar:2.0 (selected
for runtime)
[DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4 (selected for
runtime)
[DEBUG]       org.apache.maven.wagon:wagon-provider-api:jar:1.0-alpha-5
(selected for runtime)
[DEBUG]         org.codehaus.plexus:plexus-utils:jar:1.0.4 (selected for
runtime)
[DEBUG] Retrieving parent-POM from the repository for project:
null:maven-profile:jar:2.0
[DEBUG]     org.apache.maven:maven-profile:jar:2.0 (selected for runtime)
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4 (selected for
runtime)
[DEBUG]       org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
(selected for runtime)
[DEBUG]       org.apache.maven:maven-model:jar:2.0 (selected for runtime)
[WARNING] POM for: 'commons-io:commons-io:pom:1.0' does not appear to be
valid. Its will be ignored for artifa
ct resolution.

Reason: Failed to validate POM


[DEBUG]   commons-io:commons-io:jar:1.0 (selected for runtime)
[DEBUG] Retrieving parent-POM from the repository for project:
org.apache.maven:maven-plugin-api:jar:2.0
[DEBUG]   org.apache.maven:maven-plugin-api:jar:2.0 (selected for runtime)
[DEBUG] Configuring mojo
'org.apache.maven.plugins:maven-resources-plugin:2.1:resources' -->
[DEBUG]   (f) filters = []
[DEBUG]   (f) outputDirectory =
C:\Work\Eclipse\Workspace\trunk\sample-csharp\target\dotnet-assembly
[DEBUG]   (f) project = org.apache.maven.project.MavenProject@c5849c51
[DEBUG]   (f) resources = [org.apache.maven.model.Resource@1d62270]
[DEBUG] -- end configuration --
[INFO] [resources:resources]
[INFO] Using default encoding to copy filtered resources.

************************************** Comment
************************************** 
The below lines show that my dependency is found don't they?
************************************** Comment
************************************** 

[DEBUG] engn:csharp-sample:dotnet-exe:SNAPSHOT (selected for null)
[DEBUG]   nunit:nunit.framework:dotnet-library:2.2 (selected for compile)
[DEBUG] org.apache.maven.plugins:maven-compiler-plugin:maven-plugin:2.0
(selected for runtime)
[DEBUG]   org.codehaus.plexus:plexus-compiler-api:jar:1.5.1 (selected for
runtime)
[DEBUG]     org.codehaus.plexus:plexus-utils:jar:1.0.4 (selected for
runtime)
[DEBUG]     classworlds:classworlds:jar:1.1-alpha-2 (selected for runtime)
[DEBUG]     org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
(selected for runtime)
[DEBUG]       org.codehaus.plexus:plexus-utils:jar:1.0.4 (selected for
runtime)
[DEBUG]       classworlds:classworlds:jar:1.1-alpha-2 (selected for runtime)
[DEBUG]       junit:junit:jar:3.8.1 (selected for runtime)
[DEBUG]   org.codehaus.plexus:plexus-compiler-manager:jar:1.5.1 (selected
for runtime)
[DEBUG]     org.codehaus.plexus:plexus-utils:jar:1.0.4 (selected for
runtime)
[DEBUG]     org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
(selected for runtime)
[DEBUG]     org.codehaus.plexus:plexus-compiler-api:jar:1.5.1 (selected for
runtime)
[DEBUG]     classworlds:classworlds:jar:1.1-alpha-2 (selected for runtime)
[DEBUG]   org.codehaus.plexus:plexus-compiler-javac:jar:1.5.1 (selected for
runtime)
[DEBUG]     org.codehaus.plexus:plexus-utils:jar:1.0.4 (selected for
runtime)
[DEBUG]     org.codehaus.plexus:plexus-compiler-api:jar:1.5.1 (selected for
runtime)
[DEBUG]     org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
(selected for runtime)
[DEBUG]     classworlds:classworlds:jar:1.1-alpha-2 (selected for runtime)
[DEBUG]   org.apache.maven:maven-plugin-api:jar:2.0 (selected for runtime)
[DEBUG]   org.apache.maven:maven-artifact:jar:2.0 (selected for runtime)
[DEBUG]     org.codehaus.plexus:plexus-utils:jar:1.0.4 (selected for
runtime)
[DEBUG] Skipping disabled repository central
[DEBUG] plexus-compiler-csharp: using locally installed snapshot
[DEBUG] Retrieving parent-POM from the repository for project:
org.codehaus.plexus:plexus-compiler-csharp:jar:
1.6-SNAPSHOT
[DEBUG] Skipping disabled repository central
[DEBUG] plexus-compilers: resolved to version 1.6-20051023.231011-3 from
repository snapshots
[DEBUG] Retrieving parent-POM from the repository for project:
null:plexus-compilers:pom:1.6-SNAPSHOT
[DEBUG] Skipping disabled repository central
[DEBUG] plexus-compiler: resolved to version 1.6-20051023.231011-3 from
repository snapshots
[DEBUG] Retrieving parent-POM from the repository for project:
null:plexus-compiler:pom:1.6-SNAPSHOT
[DEBUG] Retrieving parent-POM from the repository for project:
org.codehaus.plexus:plexus-components:pom:1.1.4

[DEBUG]   org.codehaus.plexus:plexus-compiler-csharp:jar:1.6-SNAPSHOT
(selected for compile)
[DEBUG]     org.codehaus.plexus:plexus-utils:jar:1.0.4 (setting scope to:
compile)
[DEBUG]     org.codehaus.plexus:plexus-utils:jar:1.0.4 (selected for
compile)
[DEBUG] Skipping disabled repository central
[DEBUG] plexus-compiler-api: using locally installed snapshot
[DEBUG] Retrieving parent-POM from the repository for project:
null:plexus-compiler-api:jar:1.6-SNAPSHOT
[DEBUG] plexus-compiler: resolved to version 1.6-20051023.231011-3 from
repository snapshots
[DEBUG] Retrieving parent-POM from the repository for project:
null:plexus-compiler:pom:1.6-SNAPSHOT
[DEBUG] Retrieving parent-POM from the repository for project:
org.codehaus.plexus:plexus-components:pom:1.1.4

[DEBUG]     org.codehaus.plexus:plexus-compiler-api:jar:1.5.1 (not setting
scope to: compile; local scope runt
ime wins)
[WARNING]
        Artifact org.codehaus.plexus:plexus-compiler-api:jar:1.5.1 retains
local scope 'runtime' overriding br
oader scope 'compile'
        given by a dependency. If this is not intended, modify or remove the
local scope.

[DEBUG]     org.codehaus.plexus:plexus-compiler-api:jar:1.6-SNAPSHOT
(removed - nearer found: 1.5.1)
[DEBUG]     org.codehaus.plexus:plexus-compiler-api:jar:1.6-SNAPSHOT
(selected for compile)
[DEBUG]     org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
(setting scope to: compile)
[DEBUG]     org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-8
(selected for compile)
[DEBUG]     ant:ant-nodeps:jar:1.6.5 (selected for compile)
[WARNING] POM for: 'ant:ant:pom:1.6.5' does not appear to be valid. Its will
be ignored for artifact resolutio
n.

Reason: Parse error reading POM


[DEBUG]     ant:ant:jar:1.6.5 (selected for compile)
[DEBUG] plexus-compiler-csharp: using locally installed snapshot
[DEBUG] Configuring mojo
'org.apache.maven.plugins:maven-compiler-plugin:2.0:compile' -->
[DEBUG]   (f) basedir = C:\Work\Eclipse\Workspace\trunk\sample-csharp
[DEBUG]   (f) buildDirectory =
C:\Work\Eclipse\Workspace\trunk\sample-csharp\target
************************************** Comment
************************************** 
The line below is the crux of the problem, only my output directory is being
added to the classpath elements, my custom package type is not being added.
**************************************
************************************** 
[DEBUG]   (f) classpathElements =
[C:\Work\Eclipse\Workspace\trunk\sample-csharp\target\dotnet-assembly]
[DEBUG]   (f) compileSourceRoots =
[C:\Work\Eclipse\Workspace\trunk\sample-csharp\src\main\csharp]
[DEBUG]   (f) compilerArguments = {doc=true,
mainClass=ConsoleApplication1.ConsoleApp, target=exe}
[DEBUG]   (f) compilerId = csharp
[DEBUG]   (f) debug = true
[DEBUG]   (f) executable = csc
[DEBUG]   (f) fork = true
[DEBUG]   (f) includes = [**/*.cs]
[DEBUG]   (f) optimize = false
[DEBUG]   (f) outputDirectory =
C:\Work\Eclipse\Workspace\trunk\sample-csharp\target\dotnet-assembly
[DEBUG]   (f) outputFileName = csharp-sample-SNAPSHOT
[DEBUG]   (f) projectArtifact = engn:csharp-sample:dotnet-exe:SNAPSHOT
[DEBUG]   (f) staleMillis = 0
[DEBUG]   (f) verbose = true
[DEBUG] -- end configuration --
[INFO] [compiler:compile]
[DEBUG] Using compiler 'csharp'.
[DEBUG] Source directories:
[C:\Work\Eclipse\Workspace\trunk\sample-csharp\src\main\csharp]
[DEBUG] Classpath:
[C:\Work\Eclipse\Workspace\trunk\sample-csharp\target\dotnet-assembly]
[DEBUG] Output directory:
C:\Work\Eclipse\Workspace\trunk\sample-csharp\target\dotnet-assembly
[INFO] RESCANNING!
[DEBUG] Classpath:
[DEBUG]
C:\Work\Eclipse\Workspace\trunk\sample-csharp\target\dotnet-assembly
[DEBUG] Source roots:
[DEBUG]  C:\Work\Eclipse\Workspace\trunk\sample-csharp\src\main\csharp
Size of classpath entries:1
        classpath
entry:C:\Work\Eclipse\Workspace\trunk\sample-csharp\target\dotnet-assembly
[DEBUG] Command line options:
[DEBUG] /debug+
/doc:C:\Work\Eclipse\Workspace\trunk\sample-csharp\target\dotnet-assembly\cs
harp-sample-SNAPSH
OT.xml
/out:C:\Work\Eclipse\Workspace\trunk\sample-csharp\target\dotnet-assembly\cs
harp-sample-SNAPSHOT.exe /t
arget:exe
C:\Work\Eclipse\Workspace\trunk\sample-csharp\src\main\csharp\ConsoleApp.cs
C:\Work\Eclipse\Workspac
e\trunk\sample-csharp\src\main\csharp\Class2.cs
Compiling 2 source files to
C:\Work\Eclipse\Workspace\trunk\sample-csharp\target\dotnet-assembly
Size of classpath entries:1
        classpath
entry:C:\Work\Eclipse\Workspace\trunk\sample-csharp\target\dotnet-assembly
arg: /debug+
arg:
/doc:C:\Work\Eclipse\Workspace\trunk\sample-csharp\target\dotnet-assembly\cs
harp-sample-SNAPSHOT.xml
arg:
/out:C:\Work\Eclipse\Workspace\trunk\sample-csharp\target\dotnet-assembly\cs
harp-sample-SNAPSHOT.exe
arg: /target:exe
arg:
C:\Work\Eclipse\Workspace\trunk\sample-csharp\src\main\csharp\ConsoleApp.cs
arg: C:\Work\Eclipse\Workspace\trunk\sample-csharp\src\main\csharp\Class2.cs
Compiler command line:csc
@C:\Work\Eclipse\Workspace\trunk\sample-csharp\target\csharp-arguments
Unknown output: Microsoft (R) Visual C# .NET Compiler version 7.10.6001.4
Unknown output: for Microsoft (R) .NET Framework version 1.1.4322
Unknown output: Copyright (C) Microsoft Corporation 2001-2002. All rights
reserved.
Unknown output:
[INFO]
----------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO]
----------------------------------------------------------------------------
[INFO] Total time: 5 seconds
[INFO] Finished at: Fri Oct 28 16:12:39 BST 2005
[INFO] Final Memory: 3M/6M
[INFO]
----------------------------------------------------------------------------
 
 
[Well done if you made it this far, :o)]
 
Chris Stevenson

Dresdner Kleinwort Wasserstein 

 

 ------


--------------------------------------------------------------------------------
The information contained herein is confidential and is intended solely for the
addressee. Access by any other party is unauthorised without the express 
written permission of the sender. If you are not the intended recipient, please 
contact the sender either via the company switchboard on +44 (0)20 7623 8000, or
via e-mail return. If you have received this e-mail in error or wish to read our
e-mail disclaimer statement and monitoring policy, please refer to 
http://www.drkw.com/disc/email/ or contact the sender. 3166
--------------------------------------------------------------------------------


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org