Tag: gradle

如何将Kotlin代码编译为JavaScript以供我的LibGDX Web应用程序使用?

我试图在我的LibGDX项目中运行Kotlin代码,并且它可以在桌面应用程序中成功运行,但是到目前为止,Google Web Toolkit不支持kotlin,它只将java代码编译为JS。 libGDX wiki提到可以使用内建的Kotlin功能将kotlin代码编译成JS,那么,如何将Kotlin代码编译成JS与我的GWT webapp一起使用呢? 这是甚至可能与libGDX的当前结构,或者我应该继续尝试实施TeaVM到我的项目,它支持JVM字节码? 如果TeaVM是一个更好的解决方案,或者有任何的知识,那么我最近刚刚问了一个关于如何将TeaVM实现到LibGDX的问题: 我如何将TeaVM添加到现有的libGDX项目中? 我已经有很多的困难,现在想办法解决这个问题,任何帮助将不胜感激,因为我觉得这对我的项目非常重要!

在创建gradle插件时,把生成的java或kotlin源放到哪里?

我不太确定 – 通常在/build/generated下有一个目录,但是我想知道是否有一个标准的位置可以安全地编写源文件,这些文件也将包含在编译中? 环境变量? 我找不到文档中的任何内容。 如果重要的话,这个用例就是一个单独的kotlin文件,我把它作为一个基于配置的独立任务生成,并且希望包含在java / kotlin编译中。

如何在Gradle Kotlin构建中配置processResources任务

我有一个基于groovy的构建脚本中的以下内容。 如何在基于kotlin的脚本中执行相同的操作? processResources { filesMatching('application.properties'){ expand(project.properties) } }

在gradle kotlin中访问任务的属性

我一直在试图了解如何使用Kotlin作为Gradle的脚本语言,并且遇到了我需要在startScripts任务中访问类路径属性的问题,但是我无法弄清楚如何解决这个问题。 我的假设是,我没有得到我期望的类型,因此我需要将它转换为该类型(在我的情况下它应该是CreateStartScripts)。 现在有没有人如何将startScript任务转换为lambda方法中的CreateStartScripts? 我的脚本如下所示: import groovy.lang.GroovyObject import org.springframework.boot.gradle.plugin.* import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact buildscript { dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.2.RELEASE") } } val artifactoryUrl by project val artifactoryRepo by project plugins { java application idea } apply<SpringBootPlugin>() application { mainClassName = "com.emstar.Application" } java { sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 } distributions { getByName("main") { contents { into("/") } […]

Kotlin kapt,gradle和ebean插件构建失败

build.gradle文件看起来像: group 'styleru-ikomarov' version '0.0.1-SNAPSHOT' buildscript { ext.kotlin_version = '1.1.3' ext.html_version = "0.6.2" ext.ktor_version = "0.3.3" ext.squash_version = "0.2.2" ext.gson_version = "2.8.1" ext.ehcache_version = "3.0.0.m4" ext.jodatime_version = "2.3" ext.slf4j_version = "1.7.5" ext.ebean_version = "10.3.1" ext.ebean_plugin_version = "10.2.2" ext.ebean_querybean_generator = "10.1.2" ext.mysql_version = "5.1.6" repositories { mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "io.ebean:ebean-gradle-plugin:$ebean_plugin_version" classpath "mysql:mysql-connector-java:$mysql_version" […]

在buildscript中的分机不能被Gradle Kotlin DSL识别

在这些日子里,我正在尝试编写一些代码来体验Spring 5中的Spring反应特性和kotlin扩展,并且我还准备了一个Gradle Kotlin DSL build.gradle.kt来配置gradle build。 build.gradle.kt是从http://start.spring.io生成的Spring Boot模板代码转换而来的。 但buildscript的ext不能被Gradle检测到。 buildscript { ext { } } ext将导致Gradle生成错误。 为了使classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")和compile("org.jetbrains.kotlin:kotlin-stdlib-jre8:$kotlinVersion")能够工作,我添加了变量困难的方式。 val kotlinVersion = "1.1.4" val springBootVersion = "2.0.0.M3" 但我必须在全球顶级位置声明它们,并在buildscript复制它们。 代码: https : //github.com/hantsy/spring-reactive-sample/blob/master/kotlin-gradle/build.gradle.kts 有没有一个优雅的方法来进行ext工作? 更新 :有一些丑陋的方法: 从Gradle Kotlin DSL示例https://github.com/gradle/kotlin-dsl/tree/master/samples/project-properties ,在gradel.properties中声明属性。 kotlinVersion = 1.1.4 springBootVersion = 2.0.0.M3 并在build.gradle.kts中使用它。 buildScript{ val kotlinVersion by project } val kotlinVersion by project //another […]

我怎样才能让我的JUnit测试在我的Kotlin + Gradle项目中编译和运行?

根据上一个问题,我创建了一个Kotlin + Gradle项目。 我添加了两个源文件: SRC / HelloWorld.kt package com.example.hello fun main(args : Array<String>) { println("Hello, world!") } 测试/ HelloWorldTest.kt package com.example.hello import org.junit.Assert import org.junit.Test class HelloWorldTest { @Test fun testPasses() { Assert.assertTrue(true) } @Test fun testFails() { Assert.assertTrue(false) } } 我还将src/目录标记为源根目录,并将其作为测试源根目录。 如果我在其他地方创建与这些源文件完全相同的目录结构,并创建一个非Gradle IntelliJ项目,我可以编译并运行此代码,包括测试。 但是,在我的Gradle版本的项目中,我无法从IntelliJ IDEA构建测试。 我得到以下错误: Error:(3, 12) Kotlin: Unresolved reference: junit Error:(4, 12) […]

有没有办法使用Gradle将Kotlin类编译为JavaScript?

我正在使用Kotlin Gradle插件构建一个项目。 一般来说,我的目标是JVM,但将项目的一部分编译为JavaScript将会非常有用。 我知道在使用IntellJ插件构建项目时(如在浏览器博客文章中写入Kotlin中所述 ),项目可能会定位JavaScript,但是如何使用Gradle来实现呢? 把项目分成几个gradle模块,我很确定。

Kotlin胶囊Gradle错误

我在使用Gradle创建胶囊时遇到错误。 Failed to find Premain-Class manifest attribute in E:\Dropbox\Projects\Kotlin\Games\CSGO\Charlatano\build\libs\capsule.jar Error occurred during initialization of VM agent library failed to init: instrument CAPSULE: Client connection failed. CAPSULE EXCEPTION: Accept timed out while processing null null: null (for stack trace, run with -Dcapsule.log=verbose) Press any key to continue . . . 这是我的build.script buildscript { ext.kotlin_version = '1.1-M01' […]

Android Studio 2.2无法找到所有kotlin文件的引用

更新到Android Studio 2.2后,我不断收到所有 kotlin文件中的“ Unresolved reference ”错误。 具体失败的gradle任务是:: :app:compileStagingDebugKotlinAfterJava (对于称为StagingDebug的变体) 我迄今为止发现的唯一解决方案是运行clean 。 但我不想每次都在我的代码中进行更改。 任何帮助?