Please notice first: I don't need to include .jar files!
I want to include .java files from another java project with ant. But I don't know how and google has also no idea. My build.xml looks like this:
<project>
<!-- Main properties -->
<property name="projectname" value="rasco" />
<property name="mainclass" value="de.beyermatthias.rasco.Rasco" />
<property name="lib.dir" value="./lib/java-speech-api/src/" />
<path id="classpath">
<pathelement path="${lib.dir}"/>
</path>
<!-- Tasks -->
<!-- Clean Task -->
<target name="clean">
<delete dir="build" />
</target>
<!-- Compile Task -->
<target name="compile" depends="clean" >
<mkdir dir="build/classes" />
<javac srcdir="src" destdir="build/classes/">
</javac>
</target>
<!-- Jar Task -->
<target name="jar" depends="compile" >
<mkdir dir="build/jar" />
<jar destfile="build/jar/${projectname}.jar" basedir="build/classes/">
<manifest>
<attribute name="Main-Class" value="${mainclass}" />
</manifest>
</jar>
</target>
<!-- Run Task -->
<target name="run">
<java jar="build/jar/${projectname}.jar" fork="true" />
</target>
</project>
My project hierarchy like this:
.
├── build
│ └── classes
├── build.xml
├── lib
│ └── java-speech-api
│ ├── CHANGELOG.markdown
│ ├── CREDITS.markdown
│ ├── java-speech-api.iml
│ ├── README.markdown
│ └── src
│ ├── com
│ │ └── darkprograms
│ │ └── speech
│ │ ├── microphone
│ │ │ └── Microphone.java
│ │ ├── recognizer
│ │ │ ├── FlacEncoder.java
│ │ │ ├── GoogleResponse.java
│ │ │ └── Recognizer.java
│ │ └── synthesiser
│ │ └── Synthesiser.java
│ └── META-INF
│ └── MANIFEST.MF
└── src
└── de
└── beyermatthias
└── rasco
└── Rasco.java
Most tutorials talk about including .jar files in the classpath, but I need to include the .java files, as you can see. I hope you can help me.
You can include folders of compiled .class files, but not .java source files.
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