Tag: gradle

如何在Gradle项目中将Kotlin的字节码版本设置为Java 8?

在Kotlin项目中,什么是适当的Gradle脚本来确保我的类将被编译为字节代码ver 52(Java 8)? 出于某种原因,我的类被编译为ver 50(Java 6),即使我设置了源和目标兼容性。 至少这是Idea在构建项目之后从目录build/classes/…打开文件时显示的内容。 我目前的设置是这样的。 buildscript { ext { kotlinVersion = '1.0.5-2' springBootVersion = '1.4.2.RELEASE' } repositories { mavenCentral() } dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${kotlinVersion}") } } apply plugin: 'kotlin' apply plugin: 'org.springframework.boot' tasks.withType(JavaCompile) { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } ## I also tried this and it hasn't helped #sourceCompatibility = […]

使用Gradle构建一个与Kotlin-DSL相关的jar

这个问题已经有了一个答案: 如何将所有依赖关系包含在一个jar文件中,尽管它是针对Groovy的 我用kotlin-dsl使用gradle,代码不兼容。 我尝试使用几种方法使其工作,包括: tasks.withType<Jar> { configurations["compileClasspath"].forEach { file: File -> copy { from(zipTree(file.absoluteFile)) } } } 虽然这不起作用。 那么如何在gradle中使用kotlin-dsl来包含依赖关系呢?

在Android 4.4上添加Kotlin配置后,DexFile不包含生成的类

我有一些自定义注释与注释处理在我的应用程序中生成一些新的类。 然后我使用DexFile找到所有这些文件。 final String apkName = context.getPackageManager() .getApplicationInfo(context.getPackageName(), 0).sourceDir; final DexFile dexFile = new DexFile(apkName); final PathClassLoader classLoader = new PathClassLoader( apkName, Thread.currentThread().getContextClassLoader()); final Enumeration<String> entries = dexFile.entries(); VelocityEngine从模板和注释类中生成类。 问题是当我在我的项目中配置Kotlin我生成的类不在DexFile了,如果我的应用程序运行在Android 4.4。 在Android 6.0上一切正常。 当我试图给项目添加一些额外的依赖时,同样的情况发生在我身上。 我使用Android Studio 2.1.2和摇篮插件2.1.2。

在kotlin / spring引导中使用Gradle属性扩展

我目前正在使用gradle作为构建工具来构建Kotlin , Spring Boot服务。 我试图自动扩展在我的application.properties文件中找到的属性,使用在这里找到的步骤: https://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html#howto-automatic-expansion-gradle 我的版本如下: – kotlin: 1.1.4-3 – spring boot: 1.5.6.RELEASE – gradle: 3.5.1 当我运行./gradlew bootRun ,出现以下错误: java.lang.IllegalArgumentException: Could not resolve placeholder 'myServiceName' in value "${myServiceName}" 其次是: java.lang.IllegalStateException: LifecycleProcessor not initialized – call 'refresh' before invoking lifecycle methods via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@510aeb93: startup date [Fri Sep 15 10:59:51 AEST 2017]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@68edf5bb […]

Kotlin /本机安装错误:未找到'jni.h'文件

我已经安装了openjdk-9-jdk和jre。 我在Compiler args中添加了包含JDK C库文件的文件夹: cCompiler.args "-I/usr/lib/jvm/java-9-openjdk-amd64/include" cCompiler.args "-I/usr/lib/jvm/java-9-openjdk-amd64/include/linux" 在gradle文件中: kotlin-native-master/Interop/Indexer/build.gradle and kotlin-native-master/Interop/Runtime/build.gradle 完整的错误,我得到: 线程“main”中的异常java.lang.Error:/tmp/tmp17962303058800124468.c:2:10:致命错误:未找到'jni.h'文件 为什么会显示这个错误? 谢谢!

在Android Studio中Kotlin构建失败

错误: Error:Execution failed for task ':synclib:compileKotlin'. > com.intellij.openapi.fileTypes.LanguageFileType.<init>(Lcom/intellij/lang/Language;)V synclib模块的build.gradle文件: apply plugin: 'java' apply plugin: 'kotlin' compileJava { sourceCompatibility = 1.7 targetCompatibility = 1.7 } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' // compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.firebase:firebase-client-jvm:2.2.3' compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile project(':jamodel') } buildscript { ext.kotlin_version = '1.0.0' repositories { mavenCentral() } dependencies { classpath […]

Gradle不会导入bintray依赖项,但不会引发任何错误

我正在创建一个使用Kotlin的Squash SQL库的项目。 我已经添加了依赖到我的build.gradle文件。 运行更新时,只需完成而不输出任何错误。 但图书馆没有得到我的项目导入,并没有出现。 IntelliJ中显示的依赖关系: 我的build.gradle文件: //Kotlin Stuff, nothing changed here repositories { mavenCentral() maven { url "http://dl.bintray.com/kotlin/squash" } } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlin_version" testCompile group: 'junit', name: 'junit', version: '4.12' compile 'org.jetbrains.squash:squash:0.2.2' } //Kotlin Stuff

你如何设置Kotlin,Gradle和Web框架的Spring Loaded?

我是JVM新手,有兴趣尝试使用Kotlin进行REST风格的Web开发。 热重新加载是我习惯于从Python,Ruby和JavaScript等动态脚本语言开发的功能。 玩,Dropwizard和Spring Boot都显得有吸引力。 我会愿意使用上述任何一种,但是我一直无法得到一个简单的“保存文件,重新加载网页”的工作流与任何上述设置。 这怎么能做到呢?

任务之间的Gradle依赖关系

因此,自从添加了新的Room android架构库以来,这已经开始发生了。 我遇到了AppDatabase_Impl不存在的问题,我通过将kapt添加到注释中解决了这个问题: Android Room Persistences库和Kotlin Kotlin中的Room Persistence lib实现 Kotlin中的房间持久性库实现(Gradle错误) 我有其他的错误,我怀疑是由于AS,Kotlin和Java 8,所以我尝试更新到AS 3.0 我现在正在尝试构建时出现以下错误: Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:compileDebugSources, :app:compileDebugAndroidTestSources, :app:compileDebugUnitTestSources, :cryptocurrency-icons:generateDebugSources, :cryptocurrency-icons:mockableAndroidJar, :cryptocurrency-icons:generateDebugAndroidTestSources, :cryptocurrency-icons:compileDebugSources, :cryptocurrency-icons:compileDebugUnitTestSources, :cryptocurrency-icons:compileDebugAndroidTestSources] Error:Circular dependency between the following tasks: :app:compileDebugKotlin +— :app:dataBindingExportBuildInfoDebug | \— :app:compileDebugKotlin (*) \— :app:kaptDebugKotlin \— :app:dataBindingExportBuildInfoDebug (*) (*) – details omitted (listed previously) Information:BUILD FAILED in […]

Gradle编译在Linux上找不到tornadofx

我想用gradle编译一个kotlin应用程序。 该应用程序使用tornadofx(javafx的kotlin版本)。 在build.gradle ,我有: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version" compile 'no.tornado:tornadofx:1.7.8' compile 'com.squareup.moshi:moshi:1.5.0' compile 'com.squareup.moshi:moshi-kotlin:1.5.0' // Required for local unit tests (JUnit 4 framework) testCompile 'junit:junit:4.12' } 在MyApp.kt我有: import javafx.application.Application import tornadofx.App 当我在Windows 10上编译这个项目时,无论是使用gradle clean build还是.\gradlew clean build ,它都能编译并完美工作。 当我在Ubuntu Linux上编译这个项目时,我得到一个错误消息页面,其中包括: … e: Supertypes of the following classes cannot be resolved. […]