E:\Code\mdh>gradle build
> Task :multidemo:compileKotlin FAILED
e: E:\Code\mdh\multidemo\src\main\kotlin\com\simbalarry\multidemo\SampleController.kt: (3, 23): Unresolved reference: somelib
e: E:\Code\mdh\multidemo\src\main\kotlin\com\simbalarry\multidemo\SampleController.kt: (18, 12): Unresolved reference: Tester
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':multidemo:compileKotlin'.
> Compilation error. See log for more details
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 5s
4 actionable tasks: 1 executed, 3 up-to-date
Root Project
|
|---settings.gradle
|---somelib
| |
| |---build.gradle
| |---settings.gradle
| |---src/main/kotlin/somepackage/Tester.kt
| |---src/main/kotlin/somepackage/SomeLibApplication.kt
|
|---multidemo
| |---build.gradle
| |---settings.gradle
| |---src/main/kotlin/somepackage/SampleController.kt
| |---src/main/kotlin/somepackage/MultidemoApplication.kt
include ':somelib', ':multidemo'
Somelib/Build.Gradle
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
id 'org.jetbrains.kotlin.jvm' version '1.3.21'
id 'org.jetbrains.kotlin.plugin.spring' version '1.3.21'
}
apply plugin: 'io.spring.dependency-management'
group = 'com.simbalarry'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
compileKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xjsr305=strict']
jvmTarget = '1.8'
}
}
compileTestKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xjsr305=strict']
jvmTarget = '1.8'
}
}
Somelib/settings.gradle
pluginManagement {
repositories {
gradlePluginPortal()
}
}
rootProject.name = 'somelib'
somelib/src/main/kotlin/somepackage/tester.kt
package com.simbalarry.somelib
/*
* Created on : 17-03-2019
* Author : Nayan Kurude
*/
object Tester {
fun getOutputText(): String {
return "Sample Text"
}
}
package com.simbalarry.somelib
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
@SpringBootApplication
class SomelibApplication
fun main(args: Array<String>) {
runApplication<SomelibApplication>(*args)
}
plugins {
id 'org.springframework.boot' version '2.1.3.RELEASE'
id 'org.jetbrains.kotlin.jvm' version '1.3.21'
id 'org.jetbrains.kotlin.plugin.spring' version '1.3.21'
}
apply plugin: 'io.spring.dependency-management'
group = 'com.simbalarry'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
compile project(':somelib')
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
compileKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xjsr305=strict']
jvmTarget = '1.8'
}
}
compileTestKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xjsr305=strict']
jvmTarget = '1.8'
}
}
pluginManagement {
repositories {
gradlePluginPortal()
}
}
rootProject.name = 'multidemo'
package com.simbalarry.multidemo
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
@SpringBootApplication
class MultidemoApplication
fun main(args: Array<String>) {
runApplication<MultidemoApplication>(*args)
}
package com.simbalarry.multidemo
import com.simbalarry.somelib.Tester
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
/*
* Created on : 17-03-2019
* Author : Nayan Kurude
*/
@RestController
class SampleController {
@RequestMapping("/hello")
fun hello(): String {
return Tester.getOutputText()
}
}
谁能告诉我我哪里做错了。
正如我在评论中所说:somelib应该是一个图书馆。所以它不应该应用spring boot插件,该插件的作用是创建一个spring boot应用程序。
somelib
的build.gradle文件应该如下所示:
plugins {
id 'java-library' // 1
id 'org.springframework.boot' version '2.1.3.RELEASE' apply false // 2
id 'io.spring.dependency-management' version '1.0.6.RELEASE' //3
id 'org.jetbrains.kotlin.jvm' version '1.3.21'
id 'org.jetbrains.kotlin.plugin.spring' version '1.3.21'
}
group = 'com.simbalarry'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencyManagement { // 4
imports {
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
}
}
ext['kotlin.version'] = '1.3.21' // 5
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'com.fasterxml.jackson.module:jackson-module-kotlin'
implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
compileKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xjsr305=strict']
jvmTarget = '1.8'
}
}
compileTestKotlin {
kotlinOptions {
freeCompilerArgs = ['-Xjsr305=strict']
jvmTarget = '1.8'
}
}
一些解释(参见代码中的注释):
不管怎样,现在这个构建由于这个错误而失败,我不知道如何解决它: 错误:package some.package.impl不存在 导入一些。package.impl.roundaboutimpl; 提前感谢!
克隆此项目时https://github.com/artem-zinnatullin/droidcon-nyc-2017-puzzlers.git 该项目未能建立,我得到了一个错误。这似乎是rxjava lib中的问题,但我找不到。 }
我是Hilt的新手,我正在努力在我的多模块应用程序中实现它。经过无限次尝试,构建错误从“错误a”到“错误b”,然后是“错误c”等等。 这就是我如何开始在我的多模块应用程序中实现希尔特: 应用程序build.gradle: 考虑到这一点,我必须提到我有一个AppSettings类,在那里我存储了所有的应用程序配置(现在我已经创建了AppSettings1只是为了测试),开始时我试图将该类注入到主活动
这是用Gradle构建Kotlin+Java9项目的后续。在链接后使用Groovy的Gradle。在我的情况下,使用Kotlin DSL。 基本上我有一个梯度项目与以下结构(只有相关的内容在这里): 问题:如何让链接的post(或任何其他解决方案)中提供的解决方案运行,以便使用Java9/10环境编译带有Gradle的Kotlin DSL的Kotlin项目?
问题内容: 我对Gradle(和Java 9,说实话)还很陌生,并且我正在尝试使用Gradle构建一个简单的库项目,该项目混合了Java 9和Kotlin。更详细地讲,在Java中有一个接口,在Kotlin中有一个实现。我会在Kotlin中做所有事情,但是无论如何都是Java,所以我决定采用这种方式。 我建立在IntelliJ Idea的基础上,外部定义了1.2.0 kotlin插件和gradle
问题内容: IntelliJ IDEA 2016.3添加了将构建/运行委托给Gradle的功能。 很明显,当委托选项启用时,Gradle会执行所有操作。 我的问题是,关闭此选项时,IntelliJ到底在做什么? 我问这个问题是因为我的Gradle文件中有自定义代码,并且在IntelliJ中构建时似乎未执行此代码。当我运行时,一切正常。 问题答案: IntelliJ有自己的构建系统,称为JPS,它使