You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Hari shankar <ha...@gmail.com> on 2010/11/02 10:59:24 UTC

Inline Ant tasks not working - Namespace problem?

I got a ant build.xml invoked properly via maven antrun plugin but when i
define it inline, it doesn't work. Please assist.
I think it has to do with xmlns but not sure where to define it properly.
(To be specific am using a jacoco ant task for code coverage as described
here <http://www.eclemma.org/jacoco/trunk/doc/ant.html>)

The error that i got is

*[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-antrun-plugin:1.6:
run (default) on project xxx.sample.suite: An Ant BuildException has occure
d: The prefix "jacoco" for element "jacoco:report" is not bound. -> [Help 1]
*

<?xml version="1.0" encoding="UTF-8"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
*    xmlns:jacoco="antlib:org.jacoco.ant">*
    <modelVersion>4.0.0</modelVersion>

    <groupId>xxx.sample</groupId>
    <artifactId>xxx.sample.suite</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>

                            <target>

                             <taskdef uri="antlib:org.jacoco.ant"
resource="org/jacoco/ant/antlib.xml">
                                    <classpath

path="C:\SOFTWARES\JAVA\Java-external-jars\Jacoco\lib\jacocoant.jar" />
                            </taskdef>

                                <echo message="Base dir: ${basedir}" />


                                    <jacoco:report>

                                        <executiondata>
                                            <file file="C:/coverage.exec" />
                                        </executiondata>

                                        <structure name="Example Project">
                                            <classfiles>
                                                <fileset
                                                    dir="C:\..\bin" />
                                            </classfiles>
                                            <sourcefiles encoding="UTF-8">
                                                <fileset
                                                    dir="C:\..\src" />
                                            </sourcefiles>
                                        </structure>

                                        <html destdir="C:/report" />

                                    </jacoco:report>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

        </plugins>
    </build>
</project>

Thanks,
Hari

Re: Inline Ant tasks not working - Namespace problem?

Posted by Anders Hammar <an...@hammar.net>.
The dependency should be for the antrun-plugin. The definition of jacocoant
as a plugin is just wrong I think, it's not a plugin.
Also, I don't think you should put any xmlns in the maven project tag. Maven
is not using this, it's the antrun-plugin (which is a separated space).

Maybe you want to take this to the sonar list and ask them as it's their
stuff?

/Anders

On Wed, Nov 3, 2010 at 07:08, Hari shankar <ha...@gmail.com> wrote:

> Thanks Anders.
>
> I installed jacocoant.jar to local repo now and ensured plugin dependencies
> are resolved correctly using dependency:resolve-plugins goal. It went fine.
> But upon mvn clean package, the ant task still throws the same error.
>
> This is the modified pom.xml. (Also i have added plugin dependencies in 2
> places - one for antrun plugin itself and other as normal build dependency,
> not sure which one is right). Any pointers?
>
> <build>
>        <plugins>
>            <plugin>
>                <artifactId>maven-antrun-plugin</artifactId>
>                <version>1.6</version>
>                <executions>
>                    <execution>
>                        <phase>package</phase>
>                        <configuration>
>
>                            <target>
>                             <echo message="Base dir:
> ${maven.plugin.classpath}" />
>                                 <taskdef uri="antlib:org.jacoco.ant"
> resource="org/jacoco/ant/antlib.xml"
>
>  *classpathref="maven.plugin.classpath">*
>                                    *<!--
>                                         <classpath
>
> path="C:\SOFTWARES\JAVA\Java-external-jars\Jacoco\lib\jacocoant.jar"
>                                        />
>                                    -->*
>                                </taskdef>
>
>                                 <!--
>                                    <ant antfile="C:/build.xml"> <target
> name="report" /> </ant>
>                                -->
>
>
>                                <jacoco:report>
>
>                                    <executiondata>
>                                        <file file="C:/coverage.exec" />
>                                    </executiondata>
>
>                                    <structure name="Example Project">
>                                        <classfiles>
>                                            <fileset
>
>
> dir="C:\Workspaces\all-learning\tycho-maven-headless-build\com.ebay.sample.main\bin"
> />
>                                        </classfiles>
>                                        <sourcefiles encoding="UTF-8">
>                                            <fileset
>
>
> dir="C:\Workspaces\all-learning\tycho-maven-headless-build\com.ebay.sample.main\src"
> />
>                                        </sourcefiles>
>                                    </structure>
>
>                                    <html destdir="C:/report" />
>
>                                </jacoco:report>
>                            </target>
>                        </configuration>
>                        <goals>
>                            <goal>run</goal>
>                        </goals>
>                    </execution>
>                </executions>
>                * <dependencies>
>                    <dependency>
>                        <groupId>org.sonar</groupId>
>                        <artifactId>jacocoant</artifactId>
>                        <version>0.4.1</version>
>                    </dependency>
>                </dependencies>
>            </plugin>
>            <plugin>
>                <groupId>org.sonar</groupId>
>                <artifactId>jacocoant</artifactId>
>                <version>0.4.1</version>
>            </plugin>*
>        </plugins>
>    </build>
>
>
> Also this is the xmlns in project tag:
>
> project
>    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd"
>    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"
>    xmlns:jacoco="antlib:org.jacoco.ant">
>
>
> Thanks,
> Hari
>
> On Tue, Nov 2, 2010 at 3:43 PM, Anders Hammar <an...@hammar.net> wrote:
>
> >
> >
> http://maven.apache.org/plugins/maven-antrun-plugin/examples/customTasks.html
> >
> > You need to define a plugin dependency to jacocoant.jar. If that artifact
> > is
> > not already in the repo, you need to ad it to your repo manager.
> >
> > /Anderfs
> >
> > On Tue, Nov 2, 2010 at 10:59, Hari shankar <ha...@gmail.com> wrote:
> >
> > > I got a ant build.xml invoked properly via maven antrun plugin but when
> i
> > > define it inline, it doesn't work. Please assist.
> > > I think it has to do with xmlns but not sure where to define it
> properly.
> > > (To be specific am using a jacoco ant task for code coverage as
> described
> > > here <http://www.eclemma.org/jacoco/trunk/doc/ant.html>)
> > >
> > > The error that i got is
> > >
> > > *[ERROR] Failed to execute goal
> > > org.apache.maven.plugins:maven-antrun-plugin:1.6:
> > > run (default) on project xxx.sample.suite: An Ant BuildException has
> > occure
> > > d: The prefix "jacoco" for element "jacoco:report" is not bound. ->
> [Help
> > > 1]
> > > *
> > >
> > > <?xml version="1.0" encoding="UTF-8"?>
> > > <project
> > >    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > > http://maven.apache.org/xsd/maven-4.0.0.xsd"
> > >    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> > > http://www.w3.org/2001/XMLSchema-instance"
> > > *    xmlns:jacoco="antlib:org.jacoco.ant">*
> > >    <modelVersion>4.0.0</modelVersion>
> > >
> > >    <groupId>xxx.sample</groupId>
> > >    <artifactId>xxx.sample.suite</artifactId>
> > >    <version>1.0.0-SNAPSHOT</version>
> > >    <packaging>jar</packaging>
> > >
> > >    <build>
> > >        <plugins>
> > >            <plugin>
> > >                <artifactId>maven-antrun-plugin</artifactId>
> > >                <version>1.6</version>
> > >                <executions>
> > >                    <execution>
> > >                        <phase>package</phase>
> > >                        <configuration>
> > >
> > >                            <target>
> > >
> > >                             <taskdef uri="antlib:org.jacoco.ant"
> > > resource="org/jacoco/ant/antlib.xml">
> > >                                    <classpath
> > >
> > > path="C:\SOFTWARES\JAVA\Java-external-jars\Jacoco\lib\jacocoant.jar" />
> > >                            </taskdef>
> > >
> > >                                <echo message="Base dir: ${basedir}" />
> > >
> > >
> > >                                    <jacoco:report>
> > >
> > >                                        <executiondata>
> > >                                            <file
> file="C:/coverage.exec"
> > />
> > >                                        </executiondata>
> > >
> > >                                        <structure name="Example
> Project">
> > >                                            <classfiles>
> > >                                                <fileset
> > >                                                    dir="C:\..\bin" />
> > >                                            </classfiles>
> > >                                            <sourcefiles
> encoding="UTF-8">
> > >                                                <fileset
> > >                                                    dir="C:\..\src" />
> > >                                            </sourcefiles>
> > >                                        </structure>
> > >
> > >                                        <html destdir="C:/report" />
> > >
> > >                                    </jacoco:report>
> > >                            </target>
> > >                        </configuration>
> > >                        <goals>
> > >                            <goal>run</goal>
> > >                        </goals>
> > >                    </execution>
> > >                </executions>
> > >            </plugin>
> > >
> > >        </plugins>
> > >    </build>
> > > </project>
> > >
> > > Thanks,
> > > Hari
> > >
> >
>

Re: Inline Ant tasks not working - Namespace problem?

Posted by Hari shankar <ha...@gmail.com>.
Thanks Anders.

I installed jacocoant.jar to local repo now and ensured plugin dependencies
are resolved correctly using dependency:resolve-plugins goal. It went fine.
But upon mvn clean package, the ant task still throws the same error.

This is the modified pom.xml. (Also i have added plugin dependencies in 2
places - one for antrun plugin itself and other as normal build dependency,
not sure which one is right). Any pointers?

<build>
        <plugins>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>1.6</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>

                            <target>
                            <echo message="Base dir:
${maven.plugin.classpath}" />
                                <taskdef uri="antlib:org.jacoco.ant"
resource="org/jacoco/ant/antlib.xml"
                                    *classpathref="maven.plugin.classpath">*
                                    *<!--
                                        <classpath

path="C:\SOFTWARES\JAVA\Java-external-jars\Jacoco\lib\jacocoant.jar"
                                        />
                                    -->*
                                </taskdef>

                                <!--
                                    <ant antfile="C:/build.xml"> <target
name="report" /> </ant>
                                -->


                                <jacoco:report>

                                    <executiondata>
                                        <file file="C:/coverage.exec" />
                                    </executiondata>

                                    <structure name="Example Project">
                                        <classfiles>
                                            <fileset

dir="C:\Workspaces\all-learning\tycho-maven-headless-build\com.ebay.sample.main\bin"
/>
                                        </classfiles>
                                        <sourcefiles encoding="UTF-8">
                                            <fileset

dir="C:\Workspaces\all-learning\tycho-maven-headless-build\com.ebay.sample.main\src"
/>
                                        </sourcefiles>
                                    </structure>

                                    <html destdir="C:/report" />

                                </jacoco:report>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
               * <dependencies>
                    <dependency>
                        <groupId>org.sonar</groupId>
                        <artifactId>jacocoant</artifactId>
                        <version>0.4.1</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.sonar</groupId>
                <artifactId>jacocoant</artifactId>
                <version>0.4.1</version>
            </plugin>*
        </plugins>
    </build>


Also this is the xmlns in project tag:

project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
http://www.w3.org/2001/XMLSchema-instance"
    xmlns:jacoco="antlib:org.jacoco.ant">


Thanks,
Hari

On Tue, Nov 2, 2010 at 3:43 PM, Anders Hammar <an...@hammar.net> wrote:

>
> http://maven.apache.org/plugins/maven-antrun-plugin/examples/customTasks.html
>
> You need to define a plugin dependency to jacocoant.jar. If that artifact
> is
> not already in the repo, you need to ad it to your repo manager.
>
> /Anderfs
>
> On Tue, Nov 2, 2010 at 10:59, Hari shankar <ha...@gmail.com> wrote:
>
> > I got a ant build.xml invoked properly via maven antrun plugin but when i
> > define it inline, it doesn't work. Please assist.
> > I think it has to do with xmlns but not sure where to define it properly.
> > (To be specific am using a jacoco ant task for code coverage as described
> > here <http://www.eclemma.org/jacoco/trunk/doc/ant.html>)
> >
> > The error that i got is
> >
> > *[ERROR] Failed to execute goal
> > org.apache.maven.plugins:maven-antrun-plugin:1.6:
> > run (default) on project xxx.sample.suite: An Ant BuildException has
> occure
> > d: The prefix "jacoco" for element "jacoco:report" is not bound. -> [Help
> > 1]
> > *
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> > <project
> >    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> > http://maven.apache.org/xsd/maven-4.0.0.xsd"
> >    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> > http://www.w3.org/2001/XMLSchema-instance"
> > *    xmlns:jacoco="antlib:org.jacoco.ant">*
> >    <modelVersion>4.0.0</modelVersion>
> >
> >    <groupId>xxx.sample</groupId>
> >    <artifactId>xxx.sample.suite</artifactId>
> >    <version>1.0.0-SNAPSHOT</version>
> >    <packaging>jar</packaging>
> >
> >    <build>
> >        <plugins>
> >            <plugin>
> >                <artifactId>maven-antrun-plugin</artifactId>
> >                <version>1.6</version>
> >                <executions>
> >                    <execution>
> >                        <phase>package</phase>
> >                        <configuration>
> >
> >                            <target>
> >
> >                             <taskdef uri="antlib:org.jacoco.ant"
> > resource="org/jacoco/ant/antlib.xml">
> >                                    <classpath
> >
> > path="C:\SOFTWARES\JAVA\Java-external-jars\Jacoco\lib\jacocoant.jar" />
> >                            </taskdef>
> >
> >                                <echo message="Base dir: ${basedir}" />
> >
> >
> >                                    <jacoco:report>
> >
> >                                        <executiondata>
> >                                            <file file="C:/coverage.exec"
> />
> >                                        </executiondata>
> >
> >                                        <structure name="Example Project">
> >                                            <classfiles>
> >                                                <fileset
> >                                                    dir="C:\..\bin" />
> >                                            </classfiles>
> >                                            <sourcefiles encoding="UTF-8">
> >                                                <fileset
> >                                                    dir="C:\..\src" />
> >                                            </sourcefiles>
> >                                        </structure>
> >
> >                                        <html destdir="C:/report" />
> >
> >                                    </jacoco:report>
> >                            </target>
> >                        </configuration>
> >                        <goals>
> >                            <goal>run</goal>
> >                        </goals>
> >                    </execution>
> >                </executions>
> >            </plugin>
> >
> >        </plugins>
> >    </build>
> > </project>
> >
> > Thanks,
> > Hari
> >
>

Re: Inline Ant tasks not working - Namespace problem?

Posted by Anders Hammar <an...@hammar.net>.
http://maven.apache.org/plugins/maven-antrun-plugin/examples/customTasks.html

You need to define a plugin dependency to jacocoant.jar. If that artifact is
not already in the repo, you need to ad it to your repo manager.

/Anderfs

On Tue, Nov 2, 2010 at 10:59, Hari shankar <ha...@gmail.com> wrote:

> I got a ant build.xml invoked properly via maven antrun plugin but when i
> define it inline, it doesn't work. Please assist.
> I think it has to do with xmlns but not sure where to define it properly.
> (To be specific am using a jacoco ant task for code coverage as described
> here <http://www.eclemma.org/jacoco/trunk/doc/ant.html>)
>
> The error that i got is
>
> *[ERROR] Failed to execute goal
> org.apache.maven.plugins:maven-antrun-plugin:1.6:
> run (default) on project xxx.sample.suite: An Ant BuildException has occure
> d: The prefix "jacoco" for element "jacoco:report" is not bound. -> [Help
> 1]
> *
>
> <?xml version="1.0" encoding="UTF-8"?>
> <project
>    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
> http://maven.apache.org/xsd/maven-4.0.0.xsd"
>    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="
> http://www.w3.org/2001/XMLSchema-instance"
> *    xmlns:jacoco="antlib:org.jacoco.ant">*
>    <modelVersion>4.0.0</modelVersion>
>
>    <groupId>xxx.sample</groupId>
>    <artifactId>xxx.sample.suite</artifactId>
>    <version>1.0.0-SNAPSHOT</version>
>    <packaging>jar</packaging>
>
>    <build>
>        <plugins>
>            <plugin>
>                <artifactId>maven-antrun-plugin</artifactId>
>                <version>1.6</version>
>                <executions>
>                    <execution>
>                        <phase>package</phase>
>                        <configuration>
>
>                            <target>
>
>                             <taskdef uri="antlib:org.jacoco.ant"
> resource="org/jacoco/ant/antlib.xml">
>                                    <classpath
>
> path="C:\SOFTWARES\JAVA\Java-external-jars\Jacoco\lib\jacocoant.jar" />
>                            </taskdef>
>
>                                <echo message="Base dir: ${basedir}" />
>
>
>                                    <jacoco:report>
>
>                                        <executiondata>
>                                            <file file="C:/coverage.exec" />
>                                        </executiondata>
>
>                                        <structure name="Example Project">
>                                            <classfiles>
>                                                <fileset
>                                                    dir="C:\..\bin" />
>                                            </classfiles>
>                                            <sourcefiles encoding="UTF-8">
>                                                <fileset
>                                                    dir="C:\..\src" />
>                                            </sourcefiles>
>                                        </structure>
>
>                                        <html destdir="C:/report" />
>
>                                    </jacoco:report>
>                            </target>
>                        </configuration>
>                        <goals>
>                            <goal>run</goal>
>                        </goals>
>                    </execution>
>                </executions>
>            </plugin>
>
>        </plugins>
>    </build>
> </project>
>
> Thanks,
> Hari
>

Re: Inline Ant tasks not working - Namespace problem?

Posted by lukewpatterson <lu...@gmail.com>.
I was fighting the same issue trying to get eclemma reports integrated via
antrun.  Here's a snippet dump that "works":


<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.6</version>
<executions>
  <execution>
    <phase>test</phase>
    <configuration>
      <target xmlns:jacoco="antlib:org.jacoco.ant">
        <taskdef uri="antlib:org.jacoco.ant"
resource="org/jacoco/ant/antlib.xml">
          <classpath
            path="/home/lukewpatterson/Desktop/jacocoant.jar" />
        </taskdef>
        <jacoco:report>
          <executiondata>
            <file file="jacoco.exec" />
          </executiondata>
          <structure name="Example Project">
            <classfiles>
              <fileset dir="target/classes" />
              <fileset dir="target/test-classes" />
            </classfiles>
            <sourcefiles encoding="UTF-8">
              <fileset dir="src/main/groovy" />
              <fileset dir="src/test/groovy" />
            </sourcefiles>
          </structure>
          <html destdir="target/report" />
        </jacoco:report>
      </target>
    </configuration>
    <goals>
      <goal>run</goal>
    </goals>
  </execution>
</executions>
</plugin>

obviously I don't have my jacocoant.jar properly GAV'd yet, and have too may
hardcoded references, but the important part there is:

"<target xmlns:jacoco="antlib:org.jacoco.ant">"
-- 
View this message in context: http://maven.40175.n5.nabble.com/Inline-Ant-tasks-not-working-Namespace-problem-tp3246437p3319602.html
Sent from the Maven - Users mailing list archive at Nabble.com.

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