Tag: gradle

我如何创建一个使用Gradle构建的Kotlin项目?

我正在尝试使用IntelliJ IDEA(Ubuntu 16.04上的2016.2.5)创建一个使用Gradle构建的新Kotlin项目。 当我这样做,我马上得到一个错误消息。 这就是我想要的: 从欢迎屏幕中选择“创建新项目”。 从左侧窗格中选择“Gradle”,从右侧选择“Kotlin(Java)”。 点击下一步”。 输入“hello-world”作为ArtifactId。 点击下一步。 确保选择“从源集创建单独的模块”和“使用默认的Gradle包装器”,没有别的。 点击下一步”。 使用项目名称和位置的默认值。 点击“完成”。 然后我马上得到这个错误: Gradle 'hello-world' project refresh failed Error: Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.1-M02-12. Searched in the following locations: https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1-M02-12/kotlin-gradle-plugin-1.1-M02-12.pom https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.1-M02-12/kotlin-gradle-plugin-1.1-M02-12.jar Required by: :hello-world:unspecified 生成的build.gradle看起来像这样: version '1.0-SNAPSHOT' buildscript { ext.kotlin_version = '1.1-M02-12' repositories { mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } apply plugin: […]

java.lang.NoClassDefFoundError:kotlin / jvm / internal / intrinsics in libgdx

在我的libgdx gradle应用程序中,我有一个GroundHandler类: package com.mygdx.physics import com.badlogic.gdx.ApplicationAdapter import com.badlogic.gdx.Gdx import com.badlogic.gdx.math.Vector2 import com.badlogic.gdx.physics.box2d.Fixture import com.badlogic.gdx.physics.box2d.Body import com.badlogic.gdx.physics.box2d.BodyDef import com.badlogic.gdx.graphics.OrthographicCamera import com.badlogic.gdx.physics.box2d.PolygonShape import com.badlogic.gdx.physics.box2d.World class GroundHandler(val world: World, val camera: OrthographicCamera) { private var groundBodyDef: BodyDef = BodyDef() private var groundBox: PolygonShape = PolygonShape() private var groundBody: Body? = null fun createGround() { groundBodyDef.position.set(Vector2(0f, 10f)) groundBody = […]

用gradle-script-kotlin构建一个可执行的fat jar

我刚刚把我的构建脚本移到使用gradle-script-kotlin,使用gradle 3.4和gradle-script-kotlin 0.6。 我可以得到构建脚本生成一个jar,但清单不包括主类名称。 我已经根据我发现的其他帖子,尝试了Kt和KT的主类名。 构建脚本如下所示: /* * Copyright 2017 SixRQ Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable […]

在Gradle usin Kotlin中构建JAXB类

嗨,我有一个任务在groovy: task generateJAXBClasses() { inputs.dir 'src/main/config' outputs.dir 'src/main/java/ad/ecs/struct' def jaxbSrcDir = file("${projectDir}/src/main/java") doLast { ant.taskdef(name: 'xjc', classname: 'ad.ecs.structbuild.XJC2Task', classpath: configurations.generateJAXBClasses.asPath) ant.jaxbSrcDir = jaxbSrcDir ant.xjc( destdir: '${jaxbSrcDir}', package: 'ad.ecs.struct', schema: 'src/main/config/StructsULink.xsd', binding: 'src/main/config/MainBindings.xml', readonly: true, //header: false, argument1: '-Xsetters', argument2: '-npa', ) } } 我不知道如何在Kotlin中引用我的类ad.ecs.structbuild.XJC2Task 。 我想知道在Kotlin有没有另一种蚂蚁?

Gradle kotlin不支持的方法Dependencies.getAtoms()

刚刚用Studio 3.0 Canary 3开始一个新的Android项目使用kotlin,只是试图让它做一个gradle项目同步。 目前失败 Error:Unsupported method: Dependencies.getAtoms(). The version of Gradle you connect to does not support that method. To resolve the problem you can change/upgrade the target version of Gradle you connect to. Alternatively, you can ignore this exception and read other information from the model. 任何人都知道这是什么意思,如何解决这个问题? 可能只是需要改变一些东西的版本。 gradle包装: #Mon Jun 19 08:02:32 […]

如何正确配置Gradle的Kotlin插件?

我正在尝试构建一个基本的Gradle项目。 我的build.gradle文件如下。 我不断收到下面的错误。 我不明白,因为你可以在这里找到插件…我想我正在指向: https : //mvnrepository.com/artifact/org.jetbrains.kotlin/kotlin-gradle-plugin 更新:如果我注释掉Kotlin系列,弹簧启动插件也会发生同样的情况。 这不只是特定于Kotlin插件。 错误: Error:(21, 0) Plugin [id: 'kotlin', version: '1.1.1'] was not found in any of the following sources: – Gradle Core Plugins (not a core plugin, please see https://docs.gradle.org/3.3/userguide/standard_plugins.html for available core plugins) – Gradle Central Plugin Repository (no 'kotlin' plugin available – see https://plugins.gradle.org for available […]

在kotlin中为Gradle脚本配置IntelliJ自动完成

我正在用IntelliJ中简单的hello-world应用程序试用gradle-script-kotlin 。 但IntelliJ自动完成不会在build.gradle.kts文件中弹出。 https://github.com/gradle/gradle-script-kotlin/tree/master/samples/hello-world build.gradle.kts: apply<ApplicationPlugin>() configure<ApplicationPluginConvention> { mainClassName = ".HelloWorld" } configure<JavaPluginConvention> { setSourceCompatibility(1.8) setTargetCompatibility(1.8) } repositories { jcenter() } dependencies { testCompile("junit:junit:4.12") } settings.gradle: rootProject.buildFileName = 'build.gradle.kts' 我安装了IntelliJ kotlin插件和gradle插件,并使用gradle 3.0。 示例应用程序使用gradle命令。 如何配置IntelliJ启用build.gradle.kts文件自动完成? 我正在使用IntelliJ 2016.2.2和kotlin插件版本:1.0.3-release-IJ2016.1-120

在新的Android Studio项目中配置Kotlin

我已经安装了kotlin插件,并在studio中创建了一个新项目。 我去过工具> Kotlin>在项目中配置Kotlin,并遵循所有的步骤,但我的gradle构建不起作用。 我得到这个错误: Error:(24, 0) Declaring custom 'clean' task when using the standard Gradle lifecycle plugins is not allowed. 打开文件 有人能告诉我什么是错的,或者告诉我为kotlin安装android studio的正确方法。 谢谢。

Kotlin用Android构建问题

将Kotlin集成到一个使用multidex的大型项目中。 所以当我尝试构建时,我得到这个错误: :incrementalDesygnerDebugJavaCompilationSafeguard UP-TO-DATE :compileDesygnerDebugKotlin WARN: Failed to initialize native filesystem for Windows java.lang.RuntimeException: Could not find installation home path. Please make sure bin/idea.properties is present in the installation directory. 路径似乎正确配置和idea.properties文件似乎在那里: C:\Program Files\Android\Android Studio\bin\idea.properties 建筑物需要几分钟才能停下来,所以我从Windows的任务管理器手动停止。 当我重试 – 构建成功! 但是,当我改变一条线,并重建它再次显示相同的错误。 有时我也会得到这个: The system is out of resources. Consult the following stack trace for details. java.lang.OutOfMemoryError: PermGen […]

如何将kotlin-js-library更新为1.1.3,就像kotlin-gradle-plugin一样?

如果你看: https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/ 目前的版本是1.1.3,但是: https://repo1.maven.org/maven2/org/jetbrains/kotlin/kotlin-js-library/ 回到1.0.7。 我怎样才能触发这个更新?