Tag: intellij idea

IDEA在树中显示一个项目两次

我有一个Gradle的Kotlin项目,有两个孩子。 每当我尝试在IDEA中打开它时,其中一个孩子会在树中显示两次。 在树中,你可以看到两个顶层的项目,grpc和grp。 问题是grpc(从顶层)和grpc是grp的子项目是同一个项目。 这里是我的Gradle构建文件: 父级gradle.build: buildscript { ext.kotlin_version = '1.0.1' repositories { jcenter() mavenCentral() } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } allprojects { repositories { jcenter() mavenCentral() } } gradle.settings文件: include ':grpstd', ':grpc' grpc gradle.build: apply plugin: 'antlr' apply plugin: 'application' apply plugin: 'kotlin' mainClassName = 'sron.grpc.MainKt' compileKotlin.dependsOn generateGrammarSource generateGrammarSource { arguments += ['-package', […]

修改测试文件模板

在Kotlin类中选择“创建测试”时,我希望默认包含其他导入。 例如,目前只包含import org.testng.annotations.Test ,但是我也想import org.testng.Assert.* 。 如何修改IntelliJ中Kotlin / TestNG的测试文件模板?

Log4j2不能使用json配置文件

似乎log4j试图通过XML解析器解析.json配置文件,但是为什么? 我通过命令行参数设置log4j配置文件: -Dlog4j.configurationFile=src/log4j2.json 文件内容: { "configuration": { "appenders": { "Console": { "name": "Console", "target": "SYSTEM_OUT", "PatternLayout": { "pattern": "%date %thread %logger %message" } } }, "loggers": { "root": { "level": "debug", "appender-ref": { "ref": "Console" } } } } } 我得到: [Fatal Error] log4j2.json:1:1: Content is not allowed in prolog. ERROR StatusLogger Error parsing D:\Dev\HDelphiCrawler\src\log4j2.json […]

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 […]

如何获得IntelliJ IDEA代码完成作为Kotlin顶级函数导入静态Java方法?

在编辑Kotlin代码时,IntelliJ IDEA代码完成提示了静态Java方法,但是它导入了Java类,而不是静态方法作为顶级函数(请参阅函数作用域 )。 例如键入“chrome”并按Enter将import org.openqa.selenium.remote.DesiredCapabilities并将“chrome”替换为“DesiredCapabilities.chrome()”,而不是添加import org.openqa.selenium.remote.DesiredCapabilities.chrome并将“铬“作为”铬“。 如何获得IntelliJ IDEA代码完成作为顶级函数导入静态Java方法?

使用yeoman生成器Gradle + Kotlin无法生成新项目

我使用brew install Caskroom/cask/android-studio在Mac上安装了Android Studio 然后,我跑yo gradle-kotlin ,并得到以下错误。 我能做些什么来使我的第一个Hello World工作? 谢谢 ✔ /Volumes/Git/android/kotlin-hello-world 10:53 $ yo gradle-kotlin _—–_ | | .————————–. |–(o)–| | Welcome to the | `———´ | incredible Gradle+Kotlin | ( _´U`_ ) | generator! | /___A___\ '————————–' | ~ | __'.___.'__ ´ ` |° ´ Y ` Detecting installed Gradle version… Fetching latest […]

如何在IntelliJ IDEA中忽略Kotlin的所有警告?

曾经有一个选项可以在IntelliJ Kotlin Compiler设置中“不生成任何警告”,但看起来好像已经被删除了。 我怎样才能完全忽略警告,以便我的IntelliJ在编译之后不会切换到消息选项卡?

孩子Kotlin测试类运行所有父母测试

我正在使用Kotlin和JUnit。 我有一个父测试抽象类,其中包含一些测试实现和一些抽象测试。 @Test abstract fun testThis() @Test fun testThat() { assert(true) } 在我的孩子类中,我有testThis()的实现。 @Test override fun testThis() { assert(1 == 1) } 而在另一个孩子班,我有另一个实现: @Test override fun testThis() { assert(2 == 3) } 但是,当我运行IntelliJ的所有测试,我可以看到testThat()被调用两次,每个孩子一次。 我如何阻止这种情况发生? 我希望测试只能运行一次,作为它们各自类的一部分(在这种情况下, testThat()应该在父类中执行一次)。 我的设计有问题吗?

我怎样才能让我的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模块,我很确定。