What should be in the build.gradle file to support imports of the standard groovy libraries - maven

I had created a groovy project. It worked by itself.
After some additions I had to add a new jar of a new library into the imports.
While the whole workspace runs on Gradle, I added the appropriate Maven reference to the gradle.build file.
After running gradle cleanEclipse Eclipse the new library works OK.
But. All project references to the Groovy libraries disappeared. Foolish me, I had to put some references to them into the gradle.build, too.
The list of libraries:
groovy.util.slurpersupport
groovy.xml
org.codehaus.groovy.tools.xml
groovy.lang
But I don't know how to include them into gradle.build. I can't found them in maven repository. And even so, I have them installed in my Eclipse, and I should take these. And I can't google any help, because gradle groovy gives the results on how to call gradle from groovy, not vice versa.
Moving from plain Groovy to Gradle won't help, it is really about gradle support for calling a java library from groovy.
I have nothing against getting dependencies from Maven rep., but I don't know how to do it in my case - The problem is, that I have Eclipse 3.6. And I should use the last version of groovy for Eclipse 3.6. So, I have installed it from http://dist.codehaus.org/groovy/distributions/greclipse/snapshot/e3.6/. And I don't know what is the equivalent version in Maven - there is no info about it.

There was some error in the groovy in Eclipse installation. Now after running gradle cleanEclipse Eclipse while build.gradle has NO dependencies to groovy, almost everything runs OK, I only have to add the groovy nature to the project

Related

How to execute all test case in the “spring-boot” project with gradle?

spring-boot migrated from maven to gradle since 2.3.0.M1, so the question is tagged with gradle. link
What I want to do?
We known, spring-boot-dependencies project is managing lots of jar's version and works well, that's so great! We plan to use spring-boot-dependencies as a basic to manage jar's version in my company. sometimes we need to upgrade some of the jar in spring-boot-dependencies because of vulnerabilities, and this may cause version mismatch between jars.
I have noticed that, there is about 10*000 tests case in springboot project:
So I'd like to modify some jar's version in the spring-boot-dependencies project, and then run all test of spring-boot projects, to help me analyse is there any version mismatch。
What I did?
clone the latest code from github:https://github.com/spring-projects/spring-boot.git
run .\gradlew.bat build(work on windows) in the spring-boot project root directory.
it seems only a few tests get executed:
So, my question is how can I execute all test case in spring-boot project?
Any suggestions would be greatly appreciated!
the path buildSrc/ is for the gradle custom plugin code. You are therefore looking at the build tool test results.
your main code results will be under build/reports/... folder (of each module)

can you build a maven project inside of a gradle wrapper

It may be just that I have a general misunderstanding how gradle build works, but it feels to me that I can not build a maven file inside of a gradle build. Since gradle uses the gradle.build file, and maven uses a pom.xml, it does not seem as though I can do this. I have multiple maven projects that I would like to wrap up with a gradle wrapper. I can not find ANYTHING on whether this is even possible.
Both Maven and Gradle are build tools and you should only use one of them for a given project.
If you have existing Maven projects and like the functionality provided by the Gradle wrapper, there is a similar wrapper for Maven (note that this is currently a third-party plugin but they plan to include it in the upcoming release 3.7 of Maven).
Alternatively you could convert your projects entirely to Gradle.

Gradle wrapper fails to find javafx on build, built-in gradle works okay on build

The issue is that executing gradle commands via the wrapper will cause the compileKotlin step to fail with different mentions that it is unable to find javafx-related classes/packages.
I'm setting up the whole project structure so that all the build system is not dependent on the IDE but rather relies on using the wrapper to execute all the build.
But executing a gradlew.bat build on the command line will fail with the mentioned errors. However, executing a "build" via the embedded Gradle in Intellij works. (attached pictures)
A few things to mention:
kotlin version 1.3.50 (latest version)
gradle version in wrapper properties is 5.6.2
Build failure pic:
Build working with Gradle from Intellij:
Build from Intellij button:
Gradle config in Intellij:
I have already tried plenty of suggestions mentioned on several topics related to this one (Invalidated caches + Restart, re-importing project, generating the wrapper again, all the usual solutions you will see for this issue). None of them worked, so the issue remains. I tried switching between versions of Gradle and running the wrapper again and that didn't work, it seems that version specified for the wrapper and the Gradle distribution it pulls down does not matter since the build fails with exactly the same error on all versions.
Note that this happened quite recently after an update of Intellij Idea from version 2019.2.2 to 2019.2.3, I really hope this isn't the root issue behind it.
This is not the only project with Gradle kotlin-dsl using javafx that is failing right now: even creating a new empty project via the tornadofx-plugin for Intellij and migrating it to the kotlin-dsl will yield the same results: compileKotlin task will fail. Besides that, several older projects with gradle kotlin-dsl that were building fine from the wrapper suddenly started out giving the same error.
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import edu.sc.seis.launch4j.tasks.DefaultLaunch4jTask
plugins {
application
id("edu.sc.seis.launch4j") version "2.4.6"
kotlin("jvm") version "1.3.50"
}
group = "genericdesktopapp"
version = "1.0-SNAPSHOT"
application {
mainClassName = "root/RootKt"
}
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
implementation(kotlin(module = "reflect", version = "1.3.50"))
implementation(kotlin("stdlib-jdk8"))
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0-RC")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-javafx:1.3.0-RC")
implementation("org.slf4j:slf4j-api:1.7.21")
implementation("com.lmax:disruptor:3.3.4")
implementation("org.apache.logging.log4j:log4j-slf4j-impl:2.6.2")
implementation("org.apache.logging.log4j:log4j-api:2.6.2")
implementation("org.apache.logging.log4j:log4j-core:2.6.2")
implementation("commons-io:commons-io:2.6")
implementation("org.apache.commons:commons-text:1.6")
implementation("com.github.salomonbrys.kodein:kodein:4.1.0")
implementation("commons-validator:commons-validator:1.6")
implementation("no.tornado:tornadofx:1.7.17")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.1.0")
testRuntime("org.junit.jupiter:junit-jupiter-engine:5.1.0")
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.8"
}
tasks.withType<DefaultLaunch4jTask> {
outfile = "GenericToolbox.exe"
mainClassName = "root.Root"
productName = "GenericToolbox"
}
I expect that when I run in the command line gradlew.bat build or ./gradlew build for it to complete normally and find the related classes from javafx, like it happens when using Intellij Gradle build command.
This issue should not even happen since I'm keeping everything at java-8, I know this issue is supposed to happen to versions beyond 8. I'm also seeing in the gradle caches the stdlib-jdk7 from kotlin, I have nowhere nothing related to jdk7 specified in my Intellij configurations or in the build script, so that is also something weird happening. (even cache reset made gradle pull it back in the cache, so I'm thinking it's probably the embedded kotlin compiler from gradle that is that version).
Edit: An easy way of reproducing it (just tested it right now).
Open a command line and create a new project with gradle kotlin dsl:
mkdir testproject
cd testproject
gradle init --dsl kotlin
On the project that was generated, run the gradlew.bat build or ./gradlew build and see the compileKotlin working okay and the build is successful.
On the same project, in the generated App.kt file, in the main function, add a simple val stage = Stage() (imported from javafx).
Run again the gradlew.bat build and see that it now fails since it doesn't find javafx.
I have managed to find a way around this issue, however, it's not a proper solution since I still haven't found the cause for why that was happening, but I'll post it in case anyone else will have this issue and maybe it will be helpful.
The solution is (weirdly enough) to specify the jdk version that gradle will use when running the commands through the wrapper:
gradlew.bat build -Dorg.gradle.java.home=---path-to-jdk---
I have checked my environment variables and the java home variable already points to that same location, so somehow I believe gradle doesn't find the java home and uses something embedded (which is most likely something above java 8) which produces that error. Running through the Intellij gradle works because it is using the embedded jdk in Intellij which is also java8, so that explains why they were working through the Intellij build button from the Gradle side-window.
If anyone finds the root cause or has some other suggestion, please, feel free to share your knowledge.

Gradle - compiled generated source is not recognized in IDE

I have a multi-project gradle project, with the following child projects:
schema
client
Schema basically only contains XSD & WSDL which will be compiled (using ant XJC) & used by 'client'.
Gradle can actually compile this project without any problem in command line. But when I try to import the project into my IDE (i'm using Intellij 13), those JAXB generated classes are not recognized, and hence I cant do any work on the 'client' project.
I have the project on github: https://github.com/alexwibowo/opentext-vrd-client
'client' already specifies this dependency:
compile project(":schema")
But I guess the IDE will only recognize source that is really on the schema project (i.e. schema/src/main/java), and not generated sources.
I'm coming from the Maven world, where with the (similar) setup above, as long as 'schema' JAR is in my local maven repo, then the IDE will recognize it. Any thoughts/recommendation?
Thanks in advance!
Regards,
Alex
IDEA plugin has documentation at http://www.gradle.org/docs/current/userguide/idea_plugin.html You can modify idea.module.sourceDirs and add the generated source directories there. See an example in http://www.gradle.org/docs/current/dsl/org.gradle.plugins.ide.idea.model.IdeaModule.html

How to launch jython console from maven

This looks like exactly what I would like:
http://d.hatena.ne.jp/Yoshiori/20081125/1227615261
(in Japanese, but should be apparent what it does from the commands and output)
Unfortunately, when I try those steps, it seems the plugin no longer exists at that location. Googling for it elsewhere also failed.
In short, what I'd like is to launch a jython shell with all of the pom file dependencies available on the Jython class path (hope I got that terminology right). I have a project with a rather complex and changing set of dependencies defined in maven. If I can just launch Jython from the same pom file, then I can experiment with and script all of those classes.
Other suggestions for easily loading maven dependencies into a jython shell?
Have a look at the maven-jython-compile-plugin. This plugin allows you to deploy a standalone project that includes jython with libraries. There is a demo project that shows how to use this plugin. Specifically, look at AbstractInitJython and InitJython in the code repository on how to launch a python/jython console. It will have all the libraries of the project, all pom dependencies and all the python libraries requested.
The sourceforge umbrella project is http://mavenjython.sourceforge.net/

Resources