Unable to understand a error from gradle build -Xlint:unchecked - gradle

I got this error while building hibernate using gradle
:hibernate-entitymanager:compileTestJava
/home/jsiddharth/workspace/hibernate-orm-master/hibernate-entitymanager/src/test/java/org/hibernate/jpa/test/criteria/paths/SingularAttributeJoinTest.java:128: error: <anonymous org.hibernate.jpa.test.criteria.paths.SingularAttributeJoinTest$2> is not abstract and does not override abstract method integrate(MetadataImplementor,SessionFactoryImplementor,SessionFactoryServiceRegistry) in Integrator
return new Integrator() {
^
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
:hibernate-entitymanager:compileTestJava FAILED
FAILURE: Build failed with an exception.
I assumed that I need to run gradle with the -Xlint options, but turns out, I am doing it wrong. I got this error when I ran
./gradlew eclipse -Xlint:deprecation -Xlint:unchecked Maven settings.xml file did not exist : /home/jsiddharth/.m2/settings.xml
FAILURE: Build failed with an exception.
* What went wrong:
Problem configuring task :eclipse from command line. Unknown command-line option '-X'.
> Unknown command-line option '-X'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 16.185 secs
How do I run my build to ignore the errors ?

As to you question, the -Xlint is a Java compiler option and has nothing to do with Gradle. You can specify these options via GRADLE_OPTS which is how Gradle passes arguments to the JVM.
Specifically: GRADLE_OPTS="-Xlint:deprecation"
Anyway this is not your trouble. Have a look at the error:
SingularAttributeJoinTest$2> is not abstract and does not override abstract method integrate(MetadataImplementor,SessionFactoryImplementor,SessionFactoryServiceRegistry) in Integrator
return new Integrator() {
You have an anonymous class inside SingularAttributeJoinTest which is declared to implement Integrator but fails to implement method integrate and is not declared abstract. This kind of error can't be suppressed by a -Xlint option of course.

Related

Kotlin Gradle using dependencies

I'm trying to include org.apache.commons.net.* libraries in Kotlin using Gradle and command line.
In the dependencies in my build.gradle.kts file I wrote:
compile 'commons-net:commons-net:3.6' as it's said in the apache documentation but it gives me a weird errors as:
> Configure project :
e: D:\core\Confidential\Learn\Kotlin\build.gradle.kts:30:13: Too many characters
in a character literal ''commons-net:commons-net:3.6''
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\core\Confidential\Learn\Kotlin\build.gradle.kts' line: 30
* What went wrong:
Script compilation error:
Line 30: compile('commons-net:commons-net:3.6')
^ Too many characters in a character literal ''commons-ne
t:commons-net:3.6''
1 error
* 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
(I also tried with compile 'commons-net:commons-net:3.6' and compile group: 'commons-net', name: 'commons-net', version: '3.6').
I'm totally new with Kotlin and I'm trying to familiarize myself with it before starting Android development on IDEA.
Thanks.
Just like in Java, ' is for character literals, and " is for String literals.
You want "commons-net:commons-net:3.6".
And compile() is deprecated. Use implementation().

Converting maven to gradle of Spring Initializr

Spring Initializr is a open source project , which can be downloaded/cloned from github to run our own spring initializr. however the build of the project is maven. I want to convert it to gradle. Can anyone Help ?
I tried it with gradle init and gradle build
Gradle init is creating build.gradle and settings.gradle but gradle build is giving error.
Can someone try and post the solution
Thanks in advance
Error Details :
Task :initializr-actuator:compileTestJava FAILED
D:\Duplicate1\initializr\initializr-actuator\src\test\java\io\spring\initializr\actuate\ActuatorIntegrationTests.java:19: error: package io.spring.initializr.web does not exist
import io.spring.initializr.web.AbstractFullStackInitializrIntegrationTests;
^
D:\Duplicate1\initializr\initializr-actuator\src\test\java\io\spring\initializr\actuate\ActuatorIntegrationTests.java:35: error: cannot find symbol
extends AbstractFullStackInitializrIntegrationTests {
^
symbol: class AbstractFullStackInitializrIntegrationTests
D:\Duplicate1\initializr\initializr-actuator\src\test\java\io\spring\initializr\actuate\info\BomRangesInfoContributorTests.java:24: error: package io.spring.initializr.test.metadata does not exist
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
^
D:\Duplicate1\initializr\initializr-actuator\src\test\java\io\spring\initializr\actuate\metric\ProjectGenerationMetricsListenerTests.java:28: error: package io.spring.initializr.test.metadata does not exist
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
^
D:\Duplicate1\initializr\initializr-actuator\src\test\java\io\spring\initializr\actuate\stat\AbstractInitializrStatTests.java:23: error: package io.spring.initializr.test.metadata does not exist
import io.spring.initializr.test.metadata.InitializrMetadataTestBuilder;
^
D:\Duplicate1\initializr\initializr-actuator\src\test\java\io\spring\initializr\actuate\stat\MainControllerStatsIntegrationTests.java:24: error: package io.spring.initializr.web does not exist
import io.spring.initializr.web.AbstractFullStackInitializrIntegrationTests;
^
D:\Duplicate1\initializr\initializr-actuator\src\test\java\io\spring\initializr\actuate\stat\MainControllerStatsIntegrationTests.java:56: error: cannot find symbol
extends AbstractFullStackInitializrIntegrationTests {
^
symbol: class AbstractFullStackInitializrIntegrationTests
7 errors
FAILURE: Build failed with an exception.
What went wrong:
Execution failed for task ':initializr-actuator:compileTestJava'.
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. Run with --scan to get full insights.
Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
See https://docs.gradle.org/4.8.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 4s
11 actionable tasks: 1 executed, 10 up-to-date
Instead of converting that you can generate fresh project from following url:
https://start.spring.io/
Select Gradle Project and download the code.

Specifying multiple dependencies in gradle file

Based on references below:
https://www.petrikainulainen.net/programming/gradle/getting-started-with-gradle-dependency-management/
I believe I can specify multiple dependencies under a dependency configuration like below:
However, when I try to run gradle build, I see the following errors.
Is this not the right way to provide multiple dependencies in a gradle file?
D:\TestGradle>gradle build
FAILURE: Build failed with an exception.
* Where:
Build file 'D:\TestGradle\build-ProblemTemplate.gradle' line: 116
* What went wrong:
Could not compile build file 'D:\TestGradle\build-ProblemTemplate.gradle'.
> startup failed:
build file 'D:\TestGradle\build-ProblemTemplate.gradle': 116: expecting ')', found ',' # line 116, column 68.
toolVersions.mockitoVersion}'],
^
1 error
* 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 1s
D:\TestGradle>
Also tried removing the [] in the testCompile configuration as mentioned in answer from Jakub Wójcik below. But still get the same error.
Update
Surprisingly, removing the line break after dependency configuration name worked for me.
It worked fine with or with out [] brackets. Still don't know why this matters, but updating the thread with my findings so far.
You can try specifying the dependencies with the configuration for each one of them. I think this is most common and used way.
dependencies {
compile 'dep1'
compile 'dep2'
}
or if you really want to just pass in a comma-separated args to compile closure.
dependencies {
compile (
'dep1',
'dep2'
)
}
PS. When using $variables you need to use the GString " (double quotes).
PPS. You can pass a vararg or an array to the configuration it doesn't really matter.
For the new lines
Gradle uses groovy for its scripts and this is not a bug its intentional actually, because () or {} may be interpreted as a separate block for the compiler. Refer to Context-sensitive_grammar
Its all to Groovy parser at the end of the day :)
Try removing the [] brackets, when having multiple dependencies for a testCompile clause. Also, note that you have an extra " in the line 118.

Problems using NetBeans 8.2 and Gradle to compile clarifai-java-master

I am trying to compile clarifai-java-master with Gradle and NetBeans 8.2 (JDK 1.8), but it fails. The log is below.
Could anyone help me, please?!
Thanks!
-------------
Executing: gradle clean build
Arguments: [-c, K:\D\Dados\GitHubProjects\clarifai-java-master\settings.gradle]
:core:clean
:tests:clean
:core:generateBuildConfig
warning: [options] bootstrap class path not set in conjunction with -source 1.7
1 warning
:core:compileBuildConfig
warning: [options] bootstrap class path not set in conjunction with -source 1.7
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:core:compileJava
:core:processResources UP-TO-DATE
:core:classes
:core:jar
K:\D\Dados\GitHubProjects\clarifai-java-master\core\src\main\java\clarifai2\dto\model\ConceptModel.java:20: warning: no #return
public final PatchModelRequest mergeConcepts() {
^
K:\D\Dados\GitHubProjects\clarifai-java-master\core\src\main\java\clarifai2\dto\model\ConceptModel.java:28: warning: no #return
public final PatchModelRequest setConcepts() {
^
K:\D\Dados\GitHubProjects\clarifai-java-master\core\src\main\java\clarifai2\dto\model\ConceptModel.java:36: warning: no #return
public final PatchModelRequest removeConcepts() {
^
:core:javadoc
3 warnings
:core:javadocJar
:core:sourcesJar
:core:signArchives SKIPPED
:core:assemble
:core:compileTestJava UP-TO-DATE
:core:processTestResources UP-TO-DATE
:core:testClasses UP-TO-DATE
:core:test UP-TO-DATE
:core:check UP-TO-DATE
:core:build
:tests:compileJava UP-TO-DATE
:tests:processResources UP-TO-DATE
:tests:classes UP-TO-DATE
:tests:jar
:tests:javadoc UP-TO-DATE
:tests:javadocJar
:tests:sourcesJar
:tests:assemble
FAILURE: Build failed with an exception.
What went wrong:
Could not resolve all dependencies for configuration :tests:testCompileClasspath.
Unexpected state Evicted for parent node for dependency from com.clarifai.clarifai-api2:core:unspecified.dirty(default) to com.squareup.okhttp3:okhttp:3.4.1(default).
Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
:tests:compileTestJava
BUILD FAILED
Total time: 15.576 secs
Build failure (see the Notifications window for stacktrace): gradle clean build
I've just solved the dependencies problems adding this line:
compile "com.clarifai.clarifai-api2:core:2.2.0"
... in the dependencies sections of two files:
- build-gradle(core) and
- build-gradle(test):
... and Reload Project for core and test.

why is gradle not printing the properties file?

I am trying to execute simple print statements from in gradle/groovy but I get error
extProgram = new Properties()
extProgram.load(new FileInputStream("src/main/resources/version.txt"))
ext.appVersion=extProgram['version']
println ext.appVersion
This is the error I get
Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties.
Deprecated dynamic property: "extProgram" on "root project 'appController'", value: "{}".
2.0.193
[buildinfo] Not using buildInfo properties file for this build.
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/Documents/codebase/app-controller/build.gradle' line: 54
* What went wrong:
A problem occurred evaluating root project 'appConroller'.
> Could not find method $() for arguments [build_5vi6ltfrgdviipcvtfu5rthgs1$_run_closure3_closure22_closure23#411109d] on root project 'appController'.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 9.972 secs
This is because extProgram is assumed to be a property of the project.
Try this instead:
def extProgram = new Properties()
...
This defines extProgram as a local variable.

Resources