To build the tests the path used for the sources is
maven.test.compile.src.set
you have to do :
<maven:addPath
id="maven.test.compile.src.set"
refid="andromda.java.gen.test.src"/>
Arnaud
On 2/23/06, Sebastien Arbogast <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I'm using Maven 1.0.2 in combination with AndroMDA 3.1.
> I've managed to tune AndroMDA in order to generate test skeletons and mock
> DAO's from my UML model. That part works fine but then I have a problem
> with
> Maven.
> For current classes, AndroMDA generates 2 kinds of files :
> - those that don't need any edition are generated in a subdirectory of
> target/src directory
> - those that do need to be edited (because the developer has to add custom
> code) are generated in src/java and never overwritten.
> And to make Maven understand that there is not only src/java that contains
> source files, but also target/src, they use this little jelly trick :
>
> <j:set var="generatedSourceDir" value="${maven.build.dir}"/>
> <ant:available
> file="${maven.build.src}"
> type="dir"
> property="generatedSrcAvailable"/>
>
> <!-- ============================================================
> Adds the generated source to the compile path for
> each subproject (if any exists)
> ============================================================ -->
> <preGoal name="java:compile">
> <!-- only attempt to add the generated source to the classpath
> if we have a source directory -->
> <j:set var="sourceDirectory" value="${pom.build.sourceDirectory}"/>
> <j:if test="${!empty sourceDirectory}">
> <j:if test="${generatedSrcAvailable}">
> <ant:available
> file="${sourceDirectory}"
> type="dir"
> property="srcAvailable"/>
> <j:choose>
> <j:when test="${srcAvailable}">
> <!-- add the paths of the generated source to the
> maven compile path -->
> <ant:path
> id="andromda.java.gen.src"
> location="${generatedSourceDir}"/>
> <maven:addPath
> id="maven.compile.src.set"
> refid="andromda.java.gen.src"/>
> </j:when>
> <j:otherwise>
> <ant:path id="maven.compile.src.set">
> <!-- need to set sources present to true since
> maven thinks no source exist if the
> directory
> specified by
> pom.build.sourceDirectorydoesn't exist -->
> <j:set var="sourcesPresent" value="true"/>
> <ant:pathelement
> location="${generatedSourceDir}"/>
> </ant:path>
> </j:otherwise>
> </j:choose>
> </j:if>
> </j:if>
> </preGoal>
>
> So I tried to apply the same trick for generated tests, knowing that :
> - non-editable test sources are generated in target/test-src
> - editable test sources are generated in src/test
>
> <j:set var="generatedTestSourceDir" value="${maven.build.dir}"/>
> <ant:available
> file="${maven.build.dir}/test-src"
> type="dir"
> property="generatedTestSrcAvailable"/>
> <!-- ============================================================
> Adds the generated test source to the test compile path for
> each subproject (if any exists)
> ============================================================ -->
> <preGoal name="test:compile">
> <!-- only attempt to add the generated test source to the classpath
> if we have a source directory -->
> <j:set var="testSourceDirectory" value="${
> pom.build.unitTestSourceDirectory}"/>
> <j:if test="${!empty testSourceDirectory}">
> <j:if test="${generatedTestSrcAvailable}">
> <ant:available
> file="${testSourceDirectory}"
> type="dir"
> property="testSrcAvailable"/>
> <j:choose>
> <j:when test="${testSrcAvailable}">
> <!-- add the paths of the generated source to the
> maven compile path -->
> <ant:path
> id="andromda.java.gen.test.src"
> location="${generatedTestSourceDir}"/>
> <maven:addPath
> id="maven.test.source"
> refid="andromda.java.gen.test.src"/>
> </j:when>
> <j:otherwise>
> <ant:path id="maven.test.source">
> <!-- need to set sources present to true since
> maven thinks no source exist if the
> directory
> specified by
> pom.build.sourceDirectorydoesn't exist -->
> <j:set var="testSourcesPresent" value="true"/>
> <ant:pathelement
> location="${generatedTestSourceDir}"/>
> </ant:path>
> </j:otherwise>
> </j:choose>
> </j:if>
> </j:if>
> </preGoal>
>
> But then, when I try to run maven, I get the following error message :
>
> Unable to obtain goal [multiproject:install-callback] --
> W:\data\dev\dummytest\maven.xml:227:65: <maven:addPath> cannot find the
> path
> to add to specified by 'id': maven.test.source
>
> Does it mean that my case is desperate because there can be only one test
> source directory ? Or is there another trick ? Does Maven 2 take that kind
> of special situation into account ?
>
> Thx in advance.
>
> --
> Sébastien Arbogast
>
> Blog : http://www.sebastien-arbogast.com
> The Epseelon Project : http://www.epseelon.org
>
>