Tag: gradle

IntelliJ Idea for Kotlin @ConfigurationProperties类中不生成spring-configuration-metadata.json文件

我试图为我的基于Spring Boot的项目生成spring-configuration-metadata.json文件。 如果我使用Java @ConfigurationProperties类,它会自动正确生成: @ConfigurationProperties("myprops") public class MyProps { private String hello; public String getHello() { return hello; } public void setHello(String hello) { this.hello = hello; } } 但是,如果我使用Kotlin类,则不会生成spring-configuration-metadata.json文件(我已经尝试了gradle build和Idea Rebuild Project )。 @ConfigurationProperties("myprops") class MyProps { var hello: String? = null } AFAIK Kotlin与构造函数,getter和setter生成相同的类,并且应该像普通的Java bean一样。 任何想法为什么春季启动配置处理器不适用于Kotlin类?

如何在Android Studio中将Kotlin错误链接到源代码?

我在Android Studio中使用Kotlin插件,一切工作正常,除非在Kotlin文件中有任何编译错误或警告,在消息窗口中产生的错误消息是不可点击的 – 点击它们不会带你到相应的文件(它适用于Java文件中的错误) 这是一个错误还是只是没有实现的东西呢? 我正在使用Android Studio beta 0.8.6,构建工具20.0.0 Kotlin 0.8.11,Gradle 1.12。

Kotlin Web App | 链接的CSS文件

我是Kotlin和Java中的新成员,并以此示例开始: https : //kotlinlang.org/docs/tutorials/httpservlets.html 我使用Gradle来构建应用程序,并使其工作。 在下一步我试图链接一个CSS文件,但我总是得到404错误。 我在这里创建了css文件:src / main / resources / css / style.css Gradle将文件复制到这个位置:build / resources / main / css / style.css,我用这个路径把它链接到源代码中。 package org.jetbrains.kotlin.demo import javax.servlet.annotation.WebServlet import javax.servlet.http.HttpServlet import javax.servlet.http.HttpServletRequest import javax.servlet.http.HttpServletResponse @WebServlet(name = "Hello", value = "/hello") class HomeController : HttpServlet() { override fun doGet(req: HttpServletRequest, res: HttpServletResponse) { res.writer.write(myView("nice headline")) } […]

如何为Kotlin和Gradle设置“sourceCompatibility”?

我得到Android应用程序的java.lang.NoClassDefFoundError 。 我设法将问题隔离到对List :: replaceAll的调用。 问题是这个方法是针对Java 8的,而在某些设备上是不可用的,Kotlin / Gradle正在成功编译它。 类似的问题: java.lang.NoClassDefFoundError $$ infor $ forEach $ lambda $ 1 Kotlin 我的问题是。 有没有办法给我一个编译错误的任何时候我在我的项目中使用Java 8 SDK? 我试过像下面那样手动设置Java 1.7,但是Java 8的代码编译成功。 tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { sourceCompatibility = JavaVersion.VERSION_1_7 // Is it even relevant here? targetCompatibility = JavaVersion.VERSION_1_7 kotlinOptions { jvmTarget = "1.6" } } 同样重要的是,代码不在Android模块中。 按照预期,我的Android模块不允许使用该方法。

Kotlin需要Gradle构建库

我试图添加暴露在我的项目库。 所以,它把我引向了bintray页面 ,它说使用compile 'org.jetbrains.exposed:exposed:0.8.5' 。 我打开我的文件build.gradle ,并将该文件放入dependencies段: dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" compile 'org.jetbrains.exposed:exposed:0.8.5' } IntelliJ自动生成它,我得到以下错误 警告: 根项目“DB-Table-To-Orm”:无法构建Kotlin项目配置详细信息:java.lang.reflect.InvocationTargetException:null原因:org.gradle.api.artifacts.ResolveException:无法解析所有依赖关系配置“:compileClasspath”。 引起:org.gradle.internal.resolve.ModuleVersionNotFoundException:找不到org.jetbrains.exposed:exposed:0.8.5。 在以下位置搜索: https : //repo1.maven.org/maven2/org/jetbrains/exposed/exposed/0.8.5/exposed-0.8.5.pom https://repo1.maven.org/maven2/org /jetbrains/exposed/exposed/0.8.5/exposed-0.8.5.jar需求方:project: 所以,我在回购看,没有超出jetbrains与exposed目录的路径。 如何使用Gradle安装Exposed库? 他们有没有错误地写下路径? 我应该在项目中加入一个错误报告吗? 或者我只是把compile语句放在错误的位置? 对不起,如果这似乎是一个愚蠢的要求,我是新来的Javaland和Kotlin和IntelliJ 。 来到.NET世界。 更新 这里是完整的build.gradle : group 'com.awebsite.db-table-to-orm' version '1.0-SNAPSHOT' buildscript { ext.kotlin_version = '1.1.4-2' repositories { mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } apply […]

与Gradle一起使用Kotlin

我是Kotlin和Gradle新手,并试图遵循这些步骤,所以我得到了以下两个文件: 运行gradle init我将build.gradle改为: // set up the kotlin-gradle plugin buildscript { ext.kotlin_version = '1.1.2-2' repositories { mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } // apply the kotlin-gradle plugin apply plugin: "kotlin" apply plugin: 'application' mainClassName = "hello.main" // add kotlin-stdlib dependencies. repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" } Hello.kt : package hello […]

使用Gradle构建Kotlin项目有时会导致NoClassDefFoundError失败

我不能可靠地重现这个问题,因为它是零星的。 这是我用Gradle创建Kotlin项目时所得到的结果: Could not perform incremental compilation: Could not connect to Kotlin compile daemon Could not connect to kotlin daemon. Using fallback strategy. :myproj:compileKotlin FAILED 1 actionable task: 1 executed e: java.lang.NoClassDefFoundError: Could not initialize class kotlin.Unit warning: the '-d' option with a directory destination is ignored because '-Xbuild-file' is specified Exception in thread "Thread-25" […]

:在Gradle(混合Java + Kotlin项目)中compileKotlin失败

我有一个混合Java / Kotlin项目与以下结构: 我建立它的Gradle脚本如下所示: buildscript { ext.kotlin_version = '1.0.4' repositories { mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } apply plugin: "kotlin" apply plugin: "application" mainClassName = "com.mycopany.App" sourceSets { deploy } repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" testCompile 'junit:junit:4.11' testCompile "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version" } test.testClassesDir = project.tasks.compileTestKotlin.destinationDir task wrapper(type: Wrapper) { gradleVersion="2.7" } App.kt是一个简单的程序: […]

Kotlin崩溃无法将提供的符号转换为Dependency类型的对象:org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension_Decorated

在将kotlin版本从1.0.5-2撞到1.1.0之后,我得到一个崩溃: Error:(114, 0) Cannot convert the provided notation to an object of type Dependency: org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension_Decorated@5a39a165. The following types/formats are supported: – Instances of Dependency. – String or CharSequence values, for example 'org.gradle:gradle-core:1.0'. – Maps, for example [group: 'org.gradle', name: 'gradle-core', version: '1.0']. – FileCollections, for example files('some.jar', 'someOther.jar'). – Projects, for example project(':some:project:path'). – ClassPathNotation, […]

将Groovy gradle移植到Kotlin gradle(ext缺少或闭包转换,不确定)

我有一些Git帮手写在groovy: git.gradle: def gitHash() { def res = 'git rev-parse –short HEAD'.execute([], project.rootDir).text.trim() def diff = 'git diff'.execute([], project.rootDir).text.trim() if (diff != null && diff.length() > 0) { res += "-dirty" } return res } // method needs to be converted to closure, in order to be visible outside of script ext.gitHash = { return […]