a_s*_*ber 10 java gradle gradlew build.gradle
我在我的项目中使用 Gradle 6.1 版。
该项目的build.gradle如下:
plugins {
id 'application'
}
application {
mainClass = 'com.mytestproject.Main'
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
group 'com.mytestproject'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行这个命令时./gradlew assemble,它给了我下面给出的错误:
./gradlew assemble
FAILURE: Build failed with an exception.
* Where:
Build file '/com/myproject/build.gradle' line: 6
* What went wrong:
A problem occurred evaluating root project 'JavaTestProject'.
> Could not set unknown property 'mainClass' for extension 'application' of type org.gradle.api.plugins.internal.DefaultJavaApplication.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 484ms
Run Code Online (Sandbox Code Playgroud)
Ani*_* B. 10
将build.gradle修改为:
apply plugin: "application"
mainClassName = "com.mytestproject.Main"
sourceCompatibility = 1.8
targetCompatibility = 1.8
group 'com.mytestproject'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
}
Run Code Online (Sandbox Code Playgroud)
运行这个命令: ./gradlew build
| 归档时间: |
|
| 查看次数: |
5266 次 |
| 最近记录: |