前書き
IntelliJ IDEA でKotlinプログラムを組み始めた初心者です。
Kotlinに触れる前はC言語で書いていて、
mainClass以外のファイルも扱うプログラミングは、Kotlinが初めてです。
コードを書く前のビルド:同期化(?) の段階で下記エラーを吐かれ、紹介されたURLへ飛んでも原因が分かりません。
また、自分で書いたものでなく新規プロジェクト作成時に自動的に書かれたものであるため、何をしているのかすら分からず、手詰まり気味です。
Kotlinタグで投稿しましたが、このプログラム自体がKotlinなのかも分かりません。
「分からない」づくしで大変ですが、解決策を提示して貰えませんか。よろしくお願いします。
エラー内容
Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: build file 'D:\AppProjects\Program\build.gradle': 5: all buildscript {} blocks must appear before any plugins {} blocks in the script See https://docs.gradle.org/4.4/userguide/plugins.html#sec:plugins_block for information on the plugins {} block @ line 5, column 1. buildscript { ^ 1 error
コード本体
plugins { id 'org.jetbrains.kotlin.jvm' version '1.3.20' } buildscript { ext.kotlin_version = "1.2.60" ext.tornadofx_version = "1.7.17" ext.junit_version = "5.1.0" repositories { mavenLocal() mavenCentral() } } apply plugin: "kotlin" apply plugin: "application" apply plugin: "org.junit.platform.gradle.plugin" compileKotlin { kotlinOptions.jvmTarget = "1.8" } repositories { mavenLocal() mavenCentral() maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } } dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "no.tornado:tornadofx:$tornadofx_version" testCompile "org.junit.jupiter:junit-jupiter-api:$junit_version" testRuntime "org.junit.jupiter:junit-jupiter-engine:$junit_version" } mainClassName = "com.example.demo.app.MyApp" jar { manifest { attributes( "Class-Path": configurations.compile.collect { it.getName() }.join(" "), "Main-Class": mainClassName ) } from(configurations.compile.collect { entry -> zipTree(entry) }) { exclude "META-INF/MANIFEST.MF" exclude "META-INF/*.SF" exclude "META-INF/*.DSA" exclude "META-INF/*.RSA" } } group 'Program' version '1.0-SNAPSHOT' repositories { mavenCentral() } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" } compileKotlin { kotlinOptions.jvmTarget = "1.8" } compileTestKotlin { kotlinOptions.jvmTarget = "1.8" }
※
プログラム名:'Program'
mainClass:MyApp
としています。
試行事項
エラー文> all buildscript {} blocks must appear before any plugins {} blocks in the script
とのことなので、plugins{} を buildscript{} の後方に配置したり、buildscript{} 内の末尾に配置したり等してビルドを試しましたが、ビルドは速攻終了, エラー文は変わらずといった感じです。
バージョン情報等
IntelliJ IDEA Community Edition 2018.2.4
追記(2019/02/11 20:05)
どうやら、Android Studio によって buildscript 等が生成されたようです。
Kotlin, TornadoFXなども同様に試してみましたが、Android Studio でのみエラーが発生することが確認できました。
Pop
1Gradle プロジェクトの同期に失敗しました。基本的な機能(編集、デバッグなど)は正しく機能しません。
BuildError
1No cached version of org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.21 available for offline mode. 2Disable Gradle 'offline mode' and sync project
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/04 03:10
2019/02/11 11:11