Basically I have the following structure for a javadoc:
build
+---javadoc
+-------Module A
+-------Module B
+---Index.html
Module X are folders. I'm trying to list the folders there, ignoring subfolders, so I can create the main index. So far This is what I have:
<target name="x">
<dirset id="dist.contents" dir="build/javadoc" excludes="build/javadoc/*/**"/>
<property name="prop.dist.contents" refid="dist.contents"/>
<echo>${prop.dist.contents}</echo>
</target>
But it gives me both the the Module's folder and all its subfolders. I know it should be a little detail but I can't figure it out.
Use ls command to list directories only. It is always good to do it with the familiar ls command because this is the command you use for displaying the content of a directory. To list only the subdirectories, use the -d option with ls command like this: ls -d */. Here's the output it shows:
Use ls command to list directories only. List only subdirectories in a specific directory. Use combination of ls and grep command. Use find command to list only directories. Use tree command to list only directories. Using echo command for listing directories. The ls command in Linux is used for listing the contents of any directory.
The ls command is the basic command used to list files and directories within the Linux file system. But if you want to list only directories, ls command offers some options.
If you want to ignore all files with a specific name, you need to write the literal name of the file. In this case, you don't need to provide the full path to a specific file. This pattern will ignore all files with that particular name that are located anywhere in the project.
Change to use includes
instead of excludes
, and specify a wildcard that won't traverse sub-directories:
<dirset id="dist.contents" dir="build/javadoc" includes="*"/>
Further restrict the wildcard if needed:
<dirset id="dist.contents" dir="build/javadoc" includes="Module *"/>
Here's the docs on directory-based tasks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With