0

Context: I am trying to build a web.xml during compilation. I Use ant scripts to perform this task. The ant script uses properties defined in a properties file to complete this task.

The ant script is called using Maven-ant-plugin.

However, when I do a maven build. it fails with message "An Ant BuildException Could not load definitions from resource project.properties. It could not be found."

the Ant script looks like below:



<project name="xyz" basedir="." default="make_webxml">
<target name="make_webxml">
<taskdef resource="project.properties"/>
<echo file="${webappdir}/web.xml">
<>
<>
</target>
</project>


${webappdir} is the defined in properties file


MAVEN POM:

<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <executions>
    <execution>
      <phase>process-resources</phase>
      <configuration>
        <target>
        <ant dir="build/ant/" />
        </target>
        <tasks>  
              <ant antfile="build/ant/bld_webxml.xml" target="make_webxml"/>
        </tasks>
      </configuration>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>
  </plugin> 

Am I doing something wrong?

Thanks in advance

1 Answers1

0

If you store your project.properties file within build/ant/ directory ant is not aware to search it there. Additionally, instead of taskdef use:

<property file="build/ant/project.properties"/>

Worked on my local machine.

Here is detailed documentation:

http://ant.apache.org/manual/Tasks/property.html

Piotr Oktaba
  • 775
  • 1
  • 4
  • 14
  • Thank you Piotr, But I tried this and also tried providing a complete path to properties file. It still gives the same error. More suggestions are welcome. – maverick4084716 Sep 29 '14 at 15:48
  • I have just edited my comment. I have tested it and project.properties file from build/ant directory was included into ant build. – Piotr Oktaba Sep 29 '14 at 18:26