我正在使用 intellij Idea 为 Liferay 构建一个 portlet 服务,但我在导入 gradle 制作的模块作为依赖管理时遇到了困难
解释是
Build file 'G:\Projets\[...]\build.gradle' line: 2
A problem occurred evaluating project ':xxx-service-api'.
> Could not find method compileOnly() for arguments [{group=com.liferay, name=com.liferay.petra.lang, version=5.2.1}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
build.gradle
dependencies {
compileOnly group: "com.liferay", name: "com.liferay.petra.lang", version: "5.2.1"
compileOnly group: "com.liferay", name: "com.liferay.petra.string", version: "5.3.4"
compileOnly group: "com.liferay", name: "com.liferay.portal.aop.api", version: "3.0.5"
compileOnly group: "com.liferay.portal", name: "com.liferay.portal.kernel", version: "13.0.0"
compileOnly group: "org.osgi", name: "org.osgi.annotation.versioning", version: "1.1.2"
compileOnly group: "org.osgi", name: "org.osgi.core", version: "6.0.0"
compileOnly group: "org.osgi", name: "org.osgi.service.component.annotations", version: "1.5.1"
compileOnly group: "com.liferay", name: "com.liferay.osgi.util", version: "8.1.0"
compileOnly group: "javax.portlet", name: "portlet-api", version: "3.0.1"
compileOnly group: "org.slf4j", name: "slf4j-api", version: "1.7.2"
}
我使用 gradle 5.6.4 和 liferay dxp-7.4
如果您想使用
compileOnly
,请确保应用Java插件。
plugins {
id('java')
}
如果是新项目,我建议您使用 Blace CLI 创建 Liferay 工作区
blade init -v [Liferay version] [workspace name]
,并使用 CLI 来创建模块 blade create
。
依赖管理将由 CLI 中的默认配置处理,看起来有点像这样:
compileOnly group: "com.liferay.portal", name: "release.dxp.api"
您可以通过手动使用此包来解决您的问题,因为它包含当前依赖项中的所有代码(以及更多)
即使是现有项目,您也可以创建一个新的工作区并复制它生成的配置。
另一个问题可能是您的存储库未正确定义,因此无论如何都找不到您的依赖项。
repositories {
maven {
url "https://repository-cdn.liferay.com/nexus/content/groups/public"
}
maven {
url "https://repository.liferay.com/nexus/content/groups/public"
}
}
来源: