问题
I'm trying to display an ant patternset for debugging purposes.
In my sample the patternset is displayed as dontcompile patternSet{ includes: [] excludes: [] }
, no info from the excludesfile is shown.
I know the excludesfile is working because on Linux no windows sources are shown at the end.
build.xml
<project default="init" >
<condition property="osname" value="linux">
<os family="unix" />
</condition>
<!-- if it's not unix assume it's some kind of windows -->
<property name="osname" value="windows" />
<target name="init" >
<local name="dont_compile.os.present" />
<local name="dont_compile.present" />
<available file="dont_compile.${osname}.lst" property="dont_compile.os.present" />
<available file="dont_compile.lst" property="dont_compile.present" />
<echo>dont_compile.${osname}.lst ${dont_compile.os.present}${line.separator}dont_compile.lst ${dont_compile.present}</echo>
<patternset id="dontcompile">
<excludesfile name="dont_compile.${osname}.lst" if="dont_compile.os.present" />
<excludesfile name="dont_compile.lst" if="dont_compile.present" />
</patternset>
<fileset id="myfileset" dir=".">
<include name="**/*.source" />
<patternset refid="dontcompile" />
</fileset>
<loadfile property="os_contents" srcFile="dont_compile.${osname}.lst" />
<local name="ps.value" />
<property name="ps.value" refid="dontcompile" />
<echo>
dontcompile ${ps.value}"
os_contents ${os_contents}
${toString:myfileset}
</echo>
</target>
</project>
contents of dont_compile.linux.lst
windows.source
win/**
contents of my test directory
./build.xml
./dont_compile.linux.lst
./general.source
./linux.source
./windows.source
./win/sub.source
sample output
Buildfile: build.xml
init:
[echo] dont_compile.linux.lst true
[echo] dont_compile.lst ${dont_compile.present}
[echo]
[echo] dontcompile patternSet{ includes: [] excludes: [] }"
[echo] os_contents windows.source
[echo] win/sub.source
[echo]
[echo] general.source;linux.source
BUILD SUCCESSFUL
Total time: 0 seconds
回答1:
I found that ${toString:refid}
shows what I need.
<echo>${toString:dontcompile}</echo>
shows
patternSet{ includes: [] excludes: [windows.source, win/**] }
来源:https://stackoverflow.com/questions/60455252/how-to-display-an-ant-patternset-containing-an-excludesfile