maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alexander (JIRA)" <>
Subject [jira] [Commented] (MANTRUN-207) scriptdef ignores CDATA when there is also an element
Date Tue, 11 Sep 2018 12:51:00 GMT


Alexander commented on MANTRUN-207:

Hello [~stmsat],

I have implemented a workaround using the <script> task. The drawback is that one must
put it to each target. It would be ugly, but it will work.

Here is my code snippet. It does a simple task that is to count the number of files matched
by a fileset and fail the execution if it is not equal to the desired value.

        <!-- The script for counting of files within fileset -->
        <!-- There is no way to use the scriptdef due to the Maven bug>
        <property name="fSet.dir" value="${binary.path}"/> <!-- Directory
        <property name="fSet.includes" value="icu*.dat"/>  <!-- File Pattern
        <property name="fSet.expectedSize" value="1"/>     <!-- Validating
condition (number of files) -->

        <script language="javascript">
            // Access to Ant-Properties by their names
            fSetDir      = project.getProperty("fSet.dir");
            fSetIncludes = project.getProperty("fSet.includes");
            // Create a <fileset dir="" includes=""/>
            fSet = project.createDataType("fileset");
            fSet.setDir(new File(fSetDir));
            // Get the files (array) of that fileset
            ds = fSet.getDirectoryScanner(project);
            srcFiles = ds.getIncludedFiles();
            java.lang.System.out.println("     [custom script] " + srcFiles.length
+ " files from " +  fSetDir + " will be included to the JAR:");
            for (i = 0; i < srcFiles.length; i++) { // Print file names to console
                java.lang.System.out.println("     [custom script] " +
            // "return" the number of files as a new property with the name "fSet.Size"
            project.setNewProperty("fSet.Size", srcFiles.length);

        <fail message="Exactly ${fSet.expectedSize} files were expected, but ${fSet.Size}
found in the directory '${fSet.dir}':">
                    <equals arg1="${fSet.Size}" arg2="${fSet.expectedSize}"/>

I have upvoted the ticket and would be happy to replace this code with well-working <scriptdef>
as well.

> scriptdef ignores CDATA when there is also an element
> -----------------------------------------------------
>                 Key: MANTRUN-207
>                 URL:
>             Project: Maven Antrun Plugin
>          Issue Type: Bug
>    Affects Versions: 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8
>         Environment: Windows 10 64bit, java 1.8.0_151, maven 3.5.0
>            Reporter: Matteo Steccolini
>            Priority: Major
>         Attachments: build-main.xml, pom.xml
> When I put a CDATA node inside a scriptdef which has also an element node, the cdata
is ignored. You can see it in the attached build-main.xml that is generated from the attached
pom.xml (mvn antrun:run@hello).
> When I though I might be doing something wrong I wrote this question on stackoverflow:

This message was sent by Atlassian JIRA

View raw message