I'm not an expert on Java, but I'm trying to build a component to transcribe a podcast, using the CMU Sphinx 4 library. I'm using Eclipse Mars and Gradle to build the project as a runnable fat jar. My build.gradle looks like this.
/*
* This build file was auto generated by running the Gradle 'init' task
* by 'peter' at '03/06/16 18:34' with Gradle 2.6
*
* This generated file contains a sample Java project to get you started.
* For more details take a look at the Java Quickstart chapter in the Gradle
* user guide available at https://docs.gradle.org/2.6/userguide/tutorial_java_projects.html
*/
// Apply the java plugin to add support for Java
apply plugin: 'java'
// In this section you declare where to find the dependencies of your project
repositories {
// Use 'jcenter' for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
mavenLocal()
maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
}
// In this section you declare the dependencies for your production and test code
dependencies {
// The production code uses the SLF4J logging API at compile time
compile 'org.slf4j:slf4j-api:1.7.12'
compile group: 'edu.cmu.sphinx', name: 'sphinx4-core', version:'5prealpha-SNAPSHOT'
compile group: 'edu.cmu.sphinx', name: 'sphinx4-data', version:'5prealpha-SNAPSHOT'
// Declare the dependency for your favourite test framework you want to use in your tests.
// TestNG is also supported by the Gradle Test task. Just change the
// testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add
// 'test.useTestNG()' to your build script.
//testCompile 'junit:junit:4.12'
}
jar {
manifest {
attributes (
'Class-Path': configurations.compile.collect { it.isDirectory() ? it : zipTree(it) },
'Main-Class': 'org.conlang.sources.transcriber.Transcriber')
}
from configurations.compile.collect { entry -> zipTree(entry) }
}
Here is the manifest it produces.
Manifest-Version: 1.0
Class-Path: [ZIP '/home/peter/.gradle/caches/modules-2/files-2.1/org.s
lf4j/slf4j-api/1.7.12/8e20852d05222dc286bf1c71d78d0531e177c317/slf4j-
api-1.7.12.jar', ZIP '/home/peter/.gradle/caches/modules-2/files-2.1/
edu.cmu.sphinx/sphinx4-core/5prealpha-SNAPSHOT/523f86d4932fc124a6d497
6adbcbc4976f1ece28/sphinx4-core-5prealpha-SNAPSHOT.jar', ZIP '/home/p
eter/.gradle/caches/modules-2/files-2.1/edu.cmu.sphinx/sphinx4-data/5
prealpha-SNAPSHOT/545a2d84cfe804d18cd9926a35331546fe09f2c2/sphinx4-da
ta-5prealpha-SNAPSHOT.jar', ZIP '/home/peter/.gradle/caches/modules-2
/files-2.1/org.apache.commons/commons-math3/3.2/ec2544ab27e110d2d431b
dad7d538ed509b21e62/commons-math3-3.2.jar']
Main-Class: org.conlang.sources.transcriber.Transcriber
When I copy and paste to another directory on my own machine, the jar won't run, because Java can't find the paths in the manifest, and it certainly won't run on another machine. What do I have to change in my build.gradle to get a usable ClassPath?