I have this eclipse project that was made in eclipse by creating a gradle project. all worked well for weeks. Then i get a:
Could not run build action using Gradle distribution ‘https://services.gradle.org/distributions/gradle-4.8.1-bin.zip’.
Build file ‘D:\ray\dev\conradapps\sudoku2\build.gradle’ line: 25
A problem occurred evaluating root project ‘sudoku2’.
Could not find method application() for arguments [build_28g3nee7dn9novehuw2eeipk9$_run_closure4@255cd3c1] on root project ‘sudoku2’ of type org.gradle.api.Project. build.gradle line 25 /sudoku2 Gradle Error Marker
my build file looks like:
import java.io.IOException;
import java.nio.file.;
import java.util.;
plugins {
id ‘java’
id ‘application’
id ‘distribution’
}repositories {
jcenter()
}
sourceCompatibility = ‘1.8’
targetCompatibility = ‘1.8’
dependencies {
compile group: ‘commons-cli’, name: ‘commons-cli’, version: ‘1.3.1’
testImplementation ‘junit:junit:4.12’
}
String myMainClass=‘p.Main’
jar {
manifest {
attributes(‘Main-Class’: myMainClass)
}
}
application {
mainClassName = myMainClass
}
println(“java version is: ${JavaVersion.current()}”)
running gradlew test from the command line gets the same thing (4.8.1)
running gradle test works (5.2.1)
doing a: D:\ray\dev\conradapps\sudoku2>gradlew wrapper --gradle-version 5.2.1 gets:
FAILURE: Build failed with an exception.
Where:
Build file ‘D:\ray\dev\conradapps\sudoku2\build.gradle’ line: 25What went wrong:
A problem occurred evaluating root project ‘sudoku2’.Could not find method application() for arguments [build_28g3nee7dn9novehuw2ee
ipk9$_run_closure4@1c477e80] on root project ‘sudoku2’ of type org.gradle.api.Pr
oject.
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 3s
removing the offending: application { mainClassName = myMainClass } makes the command line gradlew and the wrapper upgrade work.
adding the application { … } back in and closing and opening the project makes the Could not find method application() for arguments in eclipse go sway.
so i was able to work around this.