gradle - 使用 Gradle 4.3.1 找不到方法 compileOnly

标签 gradle liferay liferay-dxp

在 Liferay Developer Studio 3.1.2 中,我创建了一个“New > Liferay Workspace Project”。

在其中,我创建了一个“New > Liferay Module Project”。

这是它的样子:

enter image description here

问题:模块项目上没有Gradle右键菜单。

从命令行运行 Gradle 时,我得到:

$ gradle --version

------------------------------------------------------------
Gradle 4.3.1
------------------------------------------------------------

Build time:   2017-11-08 08:59:45 UTC
Revision:     e4f4804807ef7c2829da51877861ff06e07e006d

Groovy:       2.4.12
Ant:          Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM:          1.8.0_151 (Oracle Corporation 25.151-b12)
OS:           Linux 4.4.0-101-generic amd64

$ gradle build
Starting a Gradle Daemon (subsequent builds will be faster)

FAILURE: Build failed with an exception.

* Where:
Build file '/home/nico/training-workspace/training/modules/doc-media-fragment/build.gradle' line: 2

* What went wrong:
A problem occurred evaluating root project 'doc-media-fragment'.
> Could not find method compileOnly() for arguments [{group=org.osgi, name=org.osgi.core, version=6.0.0}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

我做错了什么?
如何解决这个问题?

Liferay工作区根目录下的build.gradle是空的,下面是Liferay模块根目录下的build.gradle:

dependencies {
    compileOnly group: "org.osgi", name: "org.osgi.core", version: "6.0.0"
    compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.3.0"
}

最佳答案

您可以通过导航到 node_modules/react-native-maps/lib/android/build.gradle 并更改这些行来解决此问题

compileOnly "com.facebook.react:react-native:+"
implementation "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
implementation "com.google.android.gms:play-services-maps:$googlePlayServicesVersion"
implementation "com.google.maps.android:android-maps-utils:$androidMapsUtilsVersion"

provided "com.facebook.react:react-native:+"
compile "com.google.android.gms:play-services-base:$googlePlayServicesVersion"
compile "com.google.android.gms:play-services-maps:$googlePlayServicesVersion"
compile "com.google.maps.android:android-maps-utils:$androidMapsUtilsVersion"

并查看项目是否构建。

关于gradle - 使用 Gradle 4.3.1 找不到方法 compileOnly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47506403/

相关文章:

liferay - 由于 liferay-target-platform 的校验和不匹配而运行验证

calendar - Liferay 7 日历问题

elasticsearch - 在Liferay中搜索

java - 如何访问和显示特定用户的所有 Liferay 表单

android - 错误: no value has been specified for this provider

gradle - gradle从最终jar中不可用的任务生成的文件

android - 从Android应用程序中的gradle访问buildConfigField

android - 在gradle上无法解决来自github的依赖关系,在这种情况下该怎么办?

liferay - 使用 Liferays ADT 定制 Web 内容

maven - 为 Liferay 手动创建可部署的 JAR