Я не специалист по Java, но я пытаюсь создать компонент для транскрипции подкаста, используя библиотеку CMU Sphinx 4. Я использую Eclipse Mars и Gradle, чтобы построить проект как запутанную жировую банку. Мой build.gradle выглядит так.Gradle производит непереносные абсолютные пути в ClassPath
/*
* 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) }
}
Вот манифест, который он производит.
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
Когда я скопировать и вставить в другую папку на своей машине, банку не будет работать, потому что Java не может найти пути в манифесте, и это, конечно, не будет работать на другой машине. Что мне нужно изменить в моем build.gradle, чтобы получить полезную ClassPath?
Возможный дубликат [Использование Gradle для создания банки с зависимостями] (http://stackoverflow.com/questions/4871656/using-gradle-to-build-a-jar-with-dependencies) –