Search code examples
antclasspathacceleo

How to specify the classpath to the acceleoCompiler ant task to compile mtl files


I'm trying to compile Acceleo mtl files using an Ant task:

<target name="compileEmtsFiles">
    <echo>...... Running Acceleo mtl=emtl file compilation</echo>
    <acceleoCompiler 
        sourceFolder="src/main/java" 
        outputFolder="build/classes/main" 
        binaryResource="false" 
        dependencies="" 
        packagesToRegister="com.company.MyAcceleoPackage">
    </acceleoCompiler>
    <echo>...... Finished Acceleo mtl=emtl file compilation</echo>
</target>

But the acceleoCompiler seems to have a problem to find the "com.company.MyAcceleoPackage". It can be found in src/main/java, but I dont know how specify a kind of classpath to acceleoCompiler:

 [echo] ...... Running Acceleo mtl=emtl file compilation
 [acceleoCompiler] com.company.MyAcceleoPackage

 BUILD FAILED
 C:\path\build.acceleo.xml:24: com.company.MyAcceleoPackage

Any ideas how I can proceed?

Regards, Michael


Solution

  • I found the solution. I needed to add the bin folder to the classpath of the taskdef:

    <path id="acceleoClasspath">
        <!-- for org.eclipse.acceleo.parser_?.jar etc-->
        <fileset dir="libs">
            <include name="**/*.jar" />
        </fileset>
        <pathelement path="bin"/>
    </path>
    
    <taskdef id="acceleoCompiler" name="acceleoCompiler" 
        classname="org.eclipse.acceleo.parser.compiler.AcceleoCompiler" 
        classpathref="acceleoClasspath" />