I'm trying to get all the contents on my main classpath to get written to a file by my Ant buildscript:
<path id="main.class.path"> <fileset dir="${lib.main.dir}"> <include name="**/*.*"/> </fileset> </path>
When I hover over main.class.path
, Ant/Eclipse launches a tooltip that shows the items on that classpath:
C:\Users\myUser\workbench\eclipse\workspace\myProj\lib\main\ant-junit-1.6.5.jar
etc. (The actual list has about 30 JARs on it.)
I want this list written to a file called deps.txt under my dist/
directory.
I'm stuck because I can't figure out how to make main.class.path
an Ant variable, or how to at least access it in the <echo>
task:
<echo file="${dist.dir}/deps.txt" message="${???}"/>
Am I way-off base here, or even remotely close?!?
And for those of you out there that, instead of answering this question, would just comment Why would you want to do this?, my answer is simple: I just want a small text file in my JAR that serves as a visual reminder (for my future me) for what its dependencies are.
To check our CLASSPATH on Windows we can open a command prompt and type echo %CLASSPATH%. To check it on a Mac you need to open a terminal and type echo $CLASSPATH.
Classpath is an environment variable that is used by the application ClassLoader or system to locate and load the compiled Java bytecodes stored in the . class file. To set CLASSPATH. the CLASSPATH can be overridden by adding classpath in the manifest file and by using a command like set -classpath.
Try this:
<pathconvert property="expanded.main.class.path" refid="main.class.path"/> <target name="everything"> <echo message="${expanded.main.class.path}" file="${dist.dir}/deps.txt"/> </target>
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