我在 Liferay DXP 中为 Google Analytics API 编写了代码。我通过在 build.gradle 中写入以下 jars
compile group: 'commons-logging', name: 'commons-logging', version: '1.1.1'
compile group: 'com.google.api-client', name: 'google-api-client', version: '1.22.0'
compile group: 'com.google.api-client', name: 'google-api-client-appengine', version: '1.22.0'
compile group: 'com.google.api-client', name: 'google-api-client-gson', version: '1.22.0'
compile group: 'com.google.http-client', name: 'google-http-client-jackson2', version: '1.22.0'
compile group: 'com.google.api-client', name: 'google-api-client-java6', version: '1.22.0'
compile group: 'com.google.api-client', name: 'google-api-client-servlet', version: '1.22.0'
compile group: 'com.google.apis', name: 'google-api-services-analytics', version: 'v3-rev132-1.22.0'
compile group: 'com.google.http-client', name: 'google-http-client', version: '1.22.0'
compile group: 'com.google.http-client', name: 'google-http-client-appengine', version: '1.22.0'
compile group: 'com.google.http-client', name: 'google-http-client-gson', version: '1.22.0'
compile group: 'com.google.http-client', name: 'google-http-client-jackson2', version: '1.22.0'
compile group: 'com.google.http-client', name: 'google-http-client-jdo', version: '1.22.0'
compile group: 'com.google.oauth-client', name: 'google-oauth-client', version: '1.22.0'
compile group: 'com.google.oauth-client', name: 'google-oauth-client-appengine', version: '1.22.0'
compile group: 'com.google.oauth-client', name: 'google-oauth-client-java6', version: '1.22.0'
compile group: 'com.google.oauth-client', name: 'google-oauth-client-jetty', version: '1.22.0'
compile group: 'com.google.oauth-client', name: 'google-oauth-client-servlet', version: '1.22.0'
compile group: 'com.google.code.gson', name: 'gson', version: '2.1'
compile group: 'org.apache.httpcomponents', name: 'httpcore', version: '4.0.1'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.1.3'
compile group: 'javax.jdo', name: 'jdo2-api', version: '2.3-eb'
compile group: 'org.mortbay.jetty', name: 'jetty', version: '6.1.26'
compile group: 'org.mortbay.jetty', name: 'jetty-util', version: '6.1.26'
compile group: 'com.google.code.findbugs', name: 'jsr305', version: '1.3.9'
compile group: 'javax.transaction', name: 'transaction-api', version: '1.1'
我还使用以下代码在 bnd.bnd 文件中包含了相同的内容:
Include-Resource: @google-api-client-1.22.0.jar,@google-http-client-1.22.0.jar,@google-api-client-java6-1.22.0.jar,@google-http-client-jackson2-1.22.0.jar,@google-http-client-gson-1.22.0.jar,@google-oauth-client-1.22.0.jar,@google-oauth-client-java6-1.22.0.jar,@gson-2.1.jar,@google-api-services-analytics-v3-rev132-1.22.0.jar,@jackson-core-2.1.3.jar,@commons-logging-1.1.1.jar,@google-api-client-appengine-1.22.0.jar,@google-api-client-gson-1.22.0.jar,@google-api-client-servlet-1.22.0.jar,@google-api-services-analytics-v3-rev132-1.22.0.jar,@google-http-client-appengine-1.22.0.jar,@google-http-client-jackson2-1.22.0.jar,@google-http-client-jdo-1.22.0.jar,@google-oauth-client-appengine-1.22.0.jar,@google-oauth-client-jetty-1.22.0.jar,@google-oauth-client-servlet-1.22.0.jar,@gson-2.1.jar,@httpcore-4.0.1.jar,@jackson-core-2.1.3.jar,@jdo2-api-2.3-eb.jar,@jetty-6.1.26.jar,@jetty-util-6.1.26.jar,@jsr305-1.3.9.jar,@transaction-api-1.1.jar
该模块编译得很好,我可以得到 jar。但是当我在服务器上部署这个 jar 时,我不断收到Unresolved requirements:Import-Package:错误。
我知道问题出在传递依赖项上。我在Liferay 社区的某个地方读到,我们在 build.gradle 中提到的东西在编译时可用,它不会在编译时寻找传递依赖,但在运行时我们也需要传递依赖。
Gradle 是否有任何方法可以自行下载传递依赖项,而不是我在 build.gradle 文件中单独提及它们。