You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Mansour Al Akeel (JIRA)" <ji...@codehaus.org> on 2014/07/25 01:41:10 UTC

[jira] (MANTRUN-49) seems ignoring classpath

    [ https://jira.codehaus.org/browse/MANTRUN-49?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=350325#comment-350325 ] 

Mansour Al Akeel commented on MANTRUN-49:
-----------------------------------------

This is a bug. When taskdef completely ignores the given classpath, it's not behaving like when used in directly. I asked this on the mailing:

http://www.mail-archive.com/users@maven.apache.org/msg134338.html

And as of now, I didn't get a satisfactory answer. 
Here's an example to generate the problem:

		<profile>
			<id>db</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.maven.plugins</groupId>
						<artifactId>maven-antrun-plugin</artifactId>
						<version>1.7</version>
						<executions>
							<execution>
								<id>setup-db</id>
								<phase>process-resources</phase>
								<goals>
									<goal>run</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<target name="database-setup" description="Creates the database structure and inserts data into the database">

								<taskdef name="ddlToDatabase" classname="org.apache.ddlutils.task.DdlToDatabaseTask">
									<classpath refid="maven.plugin.classpath" />
									<classpath refid="maven.compile.classpath" />
									<classpath refid="maven.runtime.classpath" />
								</taskdef>
								<ddlToDatabase>
									<database driverClassName="org.postgresql.Driver" url="jdbc:postgresql://localhost/test" username="postgres"
										password="postgres" />
									<fileset dir="src/sql/">
										<include name="schema.xml" />
									</fileset>
									<createDatabase failonerror="true" />
									<writeSchemaToDatabase />
									<writeDataToDatabase datafile="src/sql/seeds/generated-data.xml" />
								</ddlToDatabase>
							</target>
						</configuration>
						<dependencies>
							<dependency>
								<groupId>org.apache.ddlutils</groupId>
								<artifactId>ddlutils</artifactId>
								<version>1.0</version>
							</dependency>
							<dependency>
								<groupId>log4j</groupId>
								<artifactId>log4j</artifactId>
								<version>1.2.17</version>
							</dependency>
							<!-- <dependency> -->
							<!-- <groupId>org.postgresql</groupId> -->
							<!-- <artifactId>postgresql</artifactId> -->
							<!-- <version>9.3-1100-jdbc41</version> -->
							<!-- </dependency> -->
						</dependencies>
					</plugin>
				</plugins>
			</build>
		</profile>


Please note, that when all the class path elements are omitted, taskdef still sees those classes defined in the plugin dependency. 
Which leads to the question "Does antrun taskdef recognize user defined classpath" ?



> <taskdef/> seems ignoring classpath
> -----------------------------------
>
>                 Key: MANTRUN-49
>                 URL: https://jira.codehaus.org/browse/MANTRUN-49
>             Project: Maven Antrun Plugin
>          Issue Type: Bug
>    Affects Versions: 1.2
>         Environment: Fedora
>            Reporter: Jacek Gerbszt
>            Assignee: Benson Margulies
>             Fix For: 1.6
>
>         Attachments: testcase.tar.gz
>
>
> I'm trying to run xdoclet in ant build file called from antrun plugin. The build file is very simple:
> {code:xml}
> <project name="testcase" default="run">
> 	<property name="maven.repository" value="set repository location here!"/>
> 	<property name="destdir" value="target/generated-sources"/>
> 	
> 	<path id="xdoclet.classpath">
> 		<fileset dir="${maven.repository}">
> 			<include name="commons-collections/commons-collections/3.1/commons-collections-3.1.jar"/>
> 			<include name="commons-logging/commons-logging/1.0.4/commons-logging-1.0.4.jar"/>
> 			<include name="jboss/jboss-j2ee/4.0.2/jboss-j2ee-4.0.2.jar"/>
> 			<include name="xjavadoc/xjavadoc/1.1/xjavadoc-1.1.jar"/>
> 			<include name="xdoclet/xdoclet/1.2.3/xdoclet-1.2.3.jar"/>
> 			<include name="xdoclet/xdoclet-ejb-module/1.2.3/xdoclet-ejb-module-1.2.3.jar"/>
> 		</fileset>
> 	</path>
> 	
> 	<target name="run">
> 		<!-- print classplath -->
> 		<property refid="xdoclet.classpath" name="cp"/>
> 		<echo message="xdoclet.classpath: ${cp}"/>
> 	
> 		<!-- define ejbdoclet task -->
> 		<taskdef classname="xdoclet.modules.ejb.EjbDocletTask" classpathref="xdoclet.classpath" name="ejbdoclet"/>
> 	
> 		<!-- run ejbdoclet -->
> 		<ejbdoclet destdir="${destdir}">
> 			<fileset includes="**/*Bean.java" dir="${basedir}/src/main/java"/>
> 			<remoteinterface/>
> 		</ejbdoclet>
> 	</target>
> </project>
> {code}
> When executed directly from command (ant -Dmaven.repository=/home/javor/.m2/repository) it works fine. But fails when embedded in antrun:
> {code:xml}
> <plugin>
>         <artifactId>maven-antrun-plugin</artifactId>
>         <version>1.2-SNAPSHOT</version>
>         <executions>
>           <execution>
>             <phase>generate-sources</phase>
>             <goals>
>               <goal>run</goal>
>             </goals>
>             <configuration>
>             	<tasks>
>                 	<ant inheritRefs="true" inheritall="true" antfile="build.xml">
>                 		<property name="maven.repository" value="${settings.localRepository}"/>
>                 	</ant>
>             	</tasks>
>             </configuration>
>           </execution>
>         </executions>
> </plugin>
> {code}
> Maven output:
> {noformat}
> ...
> [INFO] [antrun:run {execution: default}]
> [INFO] Executing tasks
>  
> run:
> [INFO] ------------------------------------------------------------------------
> [ERROR] BUILD ERROR
> [INFO] ------------------------------------------------------------------------
> [INFO] Error executing ant tasks
>  
> Embedded error: The following error occurred while executing this line:
> /home/javor/workspace/testcase/build.xml:26: Can't create a remoteinterface element under ejbdoclet. Make sure the jar file containing the corresponding subtask class is on the classpath specified in the <taskdef> that defined {2}.
> ...
> {noformat}
> Could you show me any workaround or put a bit of light on that problem?



--
This message was sent by Atlassian JIRA
(v6.1.6#6162)