I'm new on gradle and kotlin
When i build syntax error file using gradle build
it's just show
Execution failed for task ':compileKotlin'.
> Compilation error. See log for more details
How do i get which line syntax error like using kotlinc?
PS: using vscode, so i need it
edited
Sorry, i missed up error message because difference between gradle and kotlinc
gradle:
PS C:\PlayGround2> gradle build
e: C:\PlayGround2\src\main\kotlin\Main.kt: (26, 1): Expecting a top level declaration
> Task :compileKotlin
Using kotlin incremental compilation
...
kotlinc:
PS C:\PlayGround2\src\main\kotlin> kotlinc .\Main.kt
Main.kt:26:1: error: expecting a top level declaration
} <--- this line not shown in kotlinc
that's a known issue, someone has solved it by uninstalling all java versions and only install JDK 8.
edit: also check this link : https://github.com/waicool20/KAGA/issues/27
Have a nice day.
Related
I have so far used maven to build the java code.
I was trying to build this project which is using gradle: https://github.com/opendistro-for-elasticsearch/anomaly-detection
I followed the below steps and it is failing continuously in build.
After cloning the code,
Step 1: As per the steps mentioned in the link, I installed java first and set the Java home and path like below
yum install java-1.8.0-openjdk
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk
export PATH=$JAVA_HOME/bin:$PATH
Step 2 : I tried to build the project using gradlew like below and end up with the error,
anomaly-detection]# ./gradlew
Starting a Gradle Daemon, 1 incompatible Daemon could not be reused, use --status for details
FAILURE: Build failed with an exception.
* Where:
Build file '/host/eclipse_back/opendistro/anomaly-detection/build.gradle' line: 55
* What went wrong:
A problem occurred evaluating root project 'opendistro-anomaly-detection'.
> Failed to apply plugin [id 'elasticsearch.esplugin']
> Could not create plugin of type 'PluginBuildPlugin'.
> Could not generate a decorated class for type PluginBuildPlugin.
> org/elasticsearch/gradle/plugin/PluginPropertiesExtension has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
* 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 8s
Why it's failing? Any help is appreciated!
Thanks,
Harry
You need to setup your build environment for gradle to use a more recent java version. You can set the java version with the gradle property org.gradle.java.home:
org.gradle.java.home=<path to JDK home>
I think the problem is that you use Java 8 and in the README they want to use Java 14.
To build from command line set JAVA_HOME to point to a JDK 14 before running ./gradlew
Then it should be possible to build and test the project with the following command:
./gradlew build
EDIT:
Can you check your configuration of your IDE. Did the Gradle JVM use the correct Java version? If you are using Intellik you can check it following this post:
I want to benchmark my application using JMH.
I am using JMH with gradle as build tool.
The github repository is here.
But whenever I run the application com.demo.aerospike.JMHAerospikeSpringData I get below error.
$ gradle run
> Configure project :
Task :jmh Last added: null
> Task :run
JMHAerospikeSpringData is running ...
Exception in thread "main" java.lang.RuntimeException: ERROR: Unable to find the resource: /META-INF/BenchmarkList
at org.openjdk.jmh.runner.AbstractResourceReader.getReaders(AbstractResourceReader.java:98)
at org.openjdk.jmh.runner.BenchmarkList.find(BenchmarkList.java:122)
at org.openjdk.jmh.runner.Runner.internalRun(Runner.java:256)
at org.openjdk.jmh.runner.Runner.run(Runner.java:206)
at com.demo.aerospike.JMHAerospikeSpringData.main(JMHAerospikeSpringData.java:47)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':run'.
> Process 'command
'/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
I tried different solutions in other stackoverflow but couldn't help.
Any idea what I'm missing.
I have resolved this problem by adding this dependency to my project:
testAnnotationProcessor "org.openjdk.jmh:jmh-generator-annprocess:$jmhVersion"
next to
testImplementation "org.openjdk.jmh:jmh-core:$jmhVersion"
implementation 'org.openjdk.jmh:jmh-core:1.33'
annotationProcessor 'org.openjdk.jmh:jmh-generator-annprocess:1.33'
just like lombok
Try running without gradle daemon:
gradle --stop
gradle --no-daemon jmh
Not sure how is your project setup like because I can't find com.demo.aerospike.JMHAerospikeSpringData in your repo. Maybe you want to check this project out to get some ideas to try.
https://github.com/eugenp/tutorials/blob/master/core-java-modules/core-java-collections-maps-3/src/main/java/com/baeldung/map/concurrenthashmap/MapPerformanceComparison.java
I try to create a Griffon application as described at
http://griffon-framework.org/tutorials/1_getting_started.html#_tutorial_1_2
Using:
Gradle 2.9
lazybones 0.8.3
mvn 3.3.9
Entered:
lazybones create griffon-swing-java sample
Define value for 'group' [org.example]:
Define value for 'artifactId' [sample]:
Define value for 'version' [0.1.0-SNAPSHOT]:
Define value for 'griffonVersion' [2.7.0]:
Define value for 'package' [org.example]:
Define value for 'className' [Sample]:
Project created in sample!
cd sample
gradle run
Gives this error:
FAILURE: Build failed with an exception.
* Where:
Script '/home/username/dev/griffon_prj/sample/gradle/integration-test.gradle' line: 20
* What went wrong:
A problem occurred evaluating script.
> Could not find property 'compileOnly' on configuration container.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Am I missing something?
It sounds like a gradle configuration/script error, the gradle 2.9 version could the be problem, the tutorial mentions 2.14.
IMHO you should install gradle 2.14.1, it works fine.
I followed this tutorial and did a groovy-swing app without any problem with lazybones 0.8.3 and gradle 2.14.1.
You can have several gradle installations, each one in it's own directory, without any problem, just to take care of the path and GRADLE_HOME if you use command line (you will for the tuto).
I have this error:
ERROR
I checked my Eclipse preferences/Gradle, and the the Gradle directory is well set.
Besides, I have this stack error in my console when I try to refresh my project:
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\java\admin\build.gradle' line: 6
* What went wrong:
A problem occurred evaluating project ':admin'.
> Failed to apply plugin [class 'com.github.jengelman.gradle.plugins.shadow.ShadowJavaPlugin']
> Could not create task of type 'ShadowJar'.
Do you have any idea of what's happening here?
Thanks!
Gradle 2.11 breaks compatibility with shadowjar version 1.2.2. You can fix this by updating to shadowjar version 1.2.3.
Source: https://github.com/johnrengelman/shadow/commit/918a649b608f34dc0902d8d7aba21326ae5dfe8d
I am using new android studio for my project.
i am getting compilation error.
i am also using two external jar file in my project.
1:-commons-net-3.2.jar
2:-commons-net-3.2-sources.jar
Cant get what goes wrong please help.
following is error message.
Gradle: FAILURE: Build failed with an exception.
What went wrong: Execution failed for task ':FtpSample:compileDebug'.
Compilation failed; see the compiler error output for details.
Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
EDIT : this was a workaround available up to Android-Studio 0.2.0
One thing you can do is deactivate the external build. To do so click on "compiler settings icon".
Uncheck "Use External build
And you will see the errors in the console
I found the problem with some external jar and gradle system .
if your jar file dosent compile then just open
build.gradle--> then edit following code .
dependencies {
compile files('libs/android-support-v4.jar')
compile files('libs/your jar file')
}
i hope this help people with same error