Tag: gradle

Gradle找不到测试

我正在为我的Kotlin项目使用Spek测试框架。 我能够通过Intellij Idea Spek插件运行测试,但不能通过gradle(构建或测试)运行它们。 根据SimpleTest.kt从Idea插件1运行测试成功和1失败,当通过gradle运行它说1容器找到0测试。 如何设置通过gradle启动测试? 我的gradle和测试文件: 的build.gradle: buildscript { ext.kotlin_version = '1.1.4-2' repositories { mavenCentral() jcenter() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.junit.platform:junit-platform-gradle-plugin:1.0.0-M4" } } apply plugin: "idea" apply plugin: "java" apply plugin: "kotlin" apply plugin: "application" apply plugin: "org.junit.platform.gradle.plugin" junitPlatform { filters { engines { include 'spek' } } } mainClassName = "app.MainKt" […]

>无法应用插件>对于输入字符串:“”

我目前得到一个奇怪的错误在一台计算机上运行gradle脚本(在那里已经工作,并仍然在另一台计算机上工作)看起来像一些缓存问题 – 但删除.gradle没有帮助,我不知道如何删除另一个失败:生成失败,出现异常。 ➜ kontinuum git:(ligi_wip2) ✗ ./gradlew clean run –stacktrace Parallel execution is an incubating feature. * Where: Build file '/home/ligi/kontinuum/build.gradle' line: 15 * What went wrong: A problem occurred evaluating root project 'kontinuum'. > Failed to apply plugin [id 'kotlin'] > For input string: "" * Try: Run with –info or –debug option […]

使用Gradle无法构建Android应用程序(使用Kotlin):“comand'java.exe'以非零退出值1结束”

我正在使用Kotlin和Anko编写Android应用程序。 一切都很好,直到我创造了一些相当复杂的课程。 现在在构建Gradle给我 Dexing C:\ Programming \ AndroidStudioProjects \ ListDungeon \ app \ build \ intermediates \ transforms \ instantRunSlicer \ dev \ debug \ jars \ 1 \ 5 \ main_sliceb.jar花了1050 :app:transformClassesWithDexForDevDebug FAILED 失败:生成失败,出现异常。 什么地方出了错: 任务“:app:transformClassesWithDexForDevDebug”的执行失败。 com.android.build.api.transform.TransformException:java.lang.RuntimeException:com.android.ide.common.process.ProcessException:java.util.concurrent.ExecutionException:com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException:处理'命令'C:\ Program Files \ Java \ jdk1.8.0_31 \ bin \ java.exe''以非零退出值1结束 我尝试了一些我在这个错误上搜索的东西 清理 – 缓存失效 – 重建 […]

Kotlin gradle不能在intellij中运行的测试

我写了一些简单的扩展和一些测试。 当我通过intellij运行测试时,他们工作得很好。 作为尝试./gradlew build工作的一部分,我试图做./gradlew build ,但现在测试失败,我不知道如何进行。 扩展名: package com.example fun <T> ArrayList<T>.join(separator: String): String { return StringUtils.join(this.map {it.toString()}, separator) } fun <T> List<T>.join(separator: String): String { return StringUtils.join(this.map {it.toString()}, separator) } 测试: import com.example.join import org.junit.Assert.assertEquals import org.junit.Test class TestArrayList { @Test fun joinsToString() { val container = arrayListOf('A', 'B', 'C') assertEquals("ABC", container.join("")) // line […]

配置编译器参数

我正在寻找一种方法来配置Android应用程序项目的build.gradle文件中的Kotlin编译器参数。 我在Kotlin官方文档中看到,可以为每个构建风格(例如debug,release)配置编译器参数。 项目级的build.gradle buildscript { ext.kotlin_version = '1.1.51' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.0.0-rc1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } 应用程序级别的build.gradle […]

AssertionError:根包必须被初始化

我在Android Studio中的另一台计算机上打开我的Kotlin项目,并在事件日志中遇到错误: AssertionError:根包必须被初始化 Root package must be initialized java.lang.AssertionError: Root package must be initialized at org.jetbrains.kotlin.resolve.lazy.ResolveSession.getAllPackages(ResolveSession.java:329) at org.jetbrains.kotlin.resolve.lazy.ResolveSession.forceResolveAll(ResolveSession.java:350) at org.jetbrains.kotlin.idea.references.BuiltInsReferenceResolver$2.run(BuiltInsReferenceResolver.java:121) at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:872) at org.jetbrains.kotlin.idea.references.BuiltInsReferenceResolver$3.run(BuiltInsReferenceResolver.java:141) at com.intellij.openapi.application.impl.ApplicationImpl$8.run(ApplicationImpl.java:400) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) at org.jetbrains.ide.PooledThreadExecutor$1$1.run(PooledThreadExecutor.java:56) 项目主体结构: 的build.gradle apply plugin: 'com.android.application' apply plugin: 'kotlin-android' android { compileSdkVersion 22 buildToolsVersion "22.0.1" defaultConfig { applicationId […]

什么是.kotlin_builtins文件,我可以从我的uberjars中忽略它们?

我正在将proguard集成到我的Gradle构建中,用于在Kotlin中编写的应用程序。 我发现proguard正在剥离Kotlin标准库(就像它应该在我简单的Hello World程序中那样),但是在我的jar文件中留下了一堆扩展名为.kotlin_builtins的文件。 当我配置我的gradle任务来排除这些文件时,该程序仍然显示正常工作。 这些文件是什么,他们必须随我的可执行uberjar? 这里是我的build.gradle文件的内容供参考: buildscript { ext.kotlin_version = '1.0.5' ext.shadow_version = '1.2.4' repositories { mavenCentral() maven { url "https://plugins.gradle.org/m2/" } flatDir dirs: "gradle/proguard" } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "com.github.jengelman.gradle.plugins:shadow:$shadow_version" classpath ":proguard:" } } apply plugin: 'kotlin' apply plugin: 'application' apply plugin: 'com.github.johnrengelman.shadow' mainClassName = 'namespace.MainKt' defaultTasks 'run' repositories { mavenCentral() } dependencies […]

没有用gradle建立kotlin项目

克隆这个项目时https://github.com/artem-zinnatullin/droidcon-nyc-2017-puzzlers.git 该项目未能建立,我得到一个错误。 这似乎是rxjava库中的问题,但我找不到。 class MediumRxPuzzler2 { // What will be printed and why? @Test fun puzzler() { val observer = object : Observer<Int> { override fun onSubscribe(d: Disposable) = Unit override fun onNext(t: Int) { println("onNext $t") } override fun onComplete() { println("onComplete") } override fun onError(e: Throwable) { println("onError $e") } } Observable.just(1).subscribe(observer) Observable.just(2).subscribe(observer) […]

在使用标准Gradle生命周期插件时声明自定义的“干净”任务是不允许的

我正在构建一个kotlin android项目。 当我在android studio中配置kotlin时,我在gradle文件中得到这个错误。 Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed 这个问题已经在这里被问到,但没有帮助。 可能是什么问题?

Gradle compileKotlin includeRuntime不向jar添加运行时

我有一个Kotlin Gradle项目,我想在jar文件中包含Kotlin的运行时和stdlib。 我目前正在使用它,但是当我使用build.gradle配置构建项目时,它不包括运行时或stdlib。 compileKotlin { kotlinOptions { includeRuntime = true noStdlib = false } } 这是我使用的包含运行时/ stdlib在jar中的Gradle代码,但它不像我所期望的那样工作。 以下是一些上下文的build.gradle文件: https : //github.com/BenWoodworth/CrossPlatformGreeter/blob/bd1da79f36e70e3d88ed871bc35502ecc3a852fb/build.gradle#L35-L43 Kotlin的Gradle文档似乎表明,将kotlinOptions.includeRuntime设置为true应该在生成的.jar文件中包含Kotlin运行时。 https://kotlinlang.org/docs/reference/using-gradle.html#attributes-specific-for-kotlin 编辑:这可能是相关的。 当我运行compileKotlin时,我得到了一些与运行时相关的警告: :compileKotlin w: Classpath entry points to a non-existent location: <no_path>\lib\kotlin-runtime.jar BUILD SUCCESSFUL