怎么构建build.gradle并打包成jar?

最近写了一个非常简单的java代码,主要想用来学习使用gradle的(半只脚刚踏进java的萌新)。但是构建了好几次build.gradle,都感觉没完全成功。

简单输入“gradle run", "gradle build" 都会回复 "BUILD SUCCESSFUL in 7s,2 actionable tasks: 1 executed, 1 up-to-date“ 或者 "BUILD SUCCESSFUL in 970ms, 7 actionable tasks: 7 up-to-date"。

但是输入"gradle test" 或者 "gradle jar"时还是给一模一样的回复。这是正常的吗?还是果然运行没成功?

想向各位大佬请教一下,我这个编码是否有问题?

如果有问题,应该如何构建build.gradle呢?

我主要需要两个功能,一个是打包成jar,另一个是JUnit的测试功能。

 

非常感谢任何帮助!🙏

 

文字版本:

plugins {

// Apply the application plugin to add support for building a CLI application in Java.

id 'application'

id 'java'

}

 

repositories {

// Use JCenter for resolving dependencies.

jcenter()

mavenCentral()

}

 

dependencies {

// Use JUnit test framework.

testImplementation 'junit:junit:4.13'

 

// This dependency is used by the application.

implementation 'com.google.guava:guava:29.0-jre'

}

 

application {

// Define the main class for the application.

mainClass = 'GradleTryCatch.App'

}

 

jar {

manifest {

attributes "Main-Class": "java.GradleTryCatch.App"

}

// baseName = 'gs-gradle'

// version = '0.1.0'

}

 

plugins {
    id("org.jetbrains.intellij") version "0.6.5"
    java
}



repositories {
    // Use JCenter for resolving dependencies.
    jcenter()
    mavenCentral()
}



dependencies {
    // Use JUnit test framework.
    testImplementation("junit", "junit", "4.13")
    implementation("com.google.guava:guava:29.0-jre")
}

其他是你的,我无法改,只好删除。