我正在编译一个使用 org.json 的 java 插件。在我包含这个之前,插件能够正确编译和运行。我在 stackoverflow 上看到过类似的问题,但没有一个使用 gradle 解决这个问题。
在我的班级中,我有以下内容
import org.json.JSONArray;
import org.json.JSONObject;
我的 gradle 构建脚本包含以下内容:
repositories {
maven {
url "http://repo.dotcms.com/artifactory/libs-release"
}
mavenCentral()
flatDir {
dirs 'src/main/resources/localLibs'
}
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile fileTree(dir: 'src/main/resources/libs', include: '*.jar')
compile (group: 'com.dotcms', name: 'dotcms', version: '4.2.2'){
transitive = true
}
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.8'
compile group: 'org.json', name: 'json', version: '20170516'
compile group: 'org.simpleflatmapper', name: 'sfm-csv', version: '3.14.1'
/* Specifying an alternate configuration (see above 'configurations') keeps servlet-api.jar from being added to our own output Jar. */
providedCompile "javax.servlet:javax.servlet-api:3.1.0"
testCompile group: 'junit', name: 'junit', version: '4.12'
}
jar {
manifest {
name = 'Symplicity SOAP API Web Service'
symbolicName = 'Symplicity SOAP API Web Service'
instruction 'Bundle-Vendor', 'JustinKubicek'
instruction 'Bundle-Name', 'Symplicity SOAP API Web Service'
instruction 'Bundle-Description', 'This is a plugin to access the Symplicity SOAP API Web Service'
instruction 'Bundle-DocURL', 'https://bitbucket.org/justinkubicek/symplicity-soap-api-plugin'
instruction 'Bundle-Activator', 'com.symplicitysoapapi.soapapitool.osgi.Activator'
instruction 'DynamicImport-Package', '*'
instruction 'Import-Package', '*;version=0;'
}
}
我得到的错误是这里。
javax.servlet.ServletException: Unable to resolve Symplicity SOAP API Web Service
[197](R 197.0): missing requirement [Symplicity SOAP API Web Service [197](R 197.0)]
osgi.wiring.package; (&(osgi.wiring.package=org.json)(version>=0.0.0))
Unresolved requirements: [[Symplicity SOAP API Web Service [197](R 197.0)]
osgi.wiring.package; (&(osgi.wiring.package=org.json)(version>=0.0.0))]
Unable to start bundle
at com.dotmarketing.portlets.osgi.AJAX.OSGIAJAX.start(OSGIAJAX.java:122)
~[dotcms_4.2.2_999999.jar:?]