Gradle tasks in Spring project - java

I found gradle tasks shown below in my Eclipse Java Spring project:
application
bootRun
build
assemble
bootBuildImage
...
build setup
documentation
help
ide
verification
What these tasks are coming from? Is it part of Gradle or Spring?

(1) You ask
What these tasks are coming from?
Gradle task come from 2 area: by Gradle itself and by Gradle plug-ins.
For example, at folder where has file build.gradle , (1a) when you run command
gradle bootRun
Spring Boot application when run, it usually run and return result at http://localhost:8080 (default). gradle bootRun run success by an plugin called Spring-boot-gradle-plugin declared inside build.gradle .
(1b) When you run
gradle wrapper
your project will add some folder and files, make your source code become portable, no need install Gradle at local PC when you share for your colleagues. gradle wrapper come from Gradle itself, not from third-party one.
(2) You ask
Is it part of Gradle or Spring?
(1b) from Gradle itself, (1a) is a plug-in made by Spring team.
Reference: https://github.com/spring-projects/spring-boot/tree/master/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin

They look to be gradle as assemble, build, buildDependencies are all standard irrespective of what you are building.

Related

How to build a jar without "-SNAPSHOT" in the name with Gradle?

Every time I run this command: gradle build it produces a my-program-1.0.0-SNAPSHOT.jar. Where do I control this? In the gradle.properties I have only the version nothing else. Even if I run gradle -Dversion=1.0.0 build it still creates a jar with SNAPSHOT in the name. How do I create a jar like this: my-program-1.0.0.jar?
I'm using spring boot.
Basically we have to change the project version in the gradle, To do so we have to use project api in gradle. you can refer https://docs.gradle.org/current/dsl/org.gradle.api.Project.html
One Solution I can suggest is:
Add version '1.0' in your build.gradle

How to call Gradle build task from Gulp build running in Node.js environment

I have added Gradle to my project to manages Java dependencies, it basically fetches all the jars from maven and then runs a copy task to copy all the jars to a destination folder.
I run the Gradle from the command line at the project root folder:
gradle build //fetch all the jars
gradle copyJarsToDest //a custom Gradle task to copy all the runtime environment dependencies
Now I am asked to integrate my Gradle task into an existing Gulp Build task. The Gulp Build is running in Node.js environment and uses Babel for the latest JavaScript features. The Gulp Build pulls the code from Git repository, compiles the JavaScript and Java code, then put them into jars that can be deployed to our servers. When I start to look into how to call my Gradle task from Gulp, I only see the various posts about calling Gulp from Gradle, nothing on calling Gradle from Gulp.
Any ideas on how to call Gradle within Gulp? I am new to Gulp, I don't know if there is a way for me to ask Gulp to execute command lines "gradle build" and "gradle copyJarstoDest"? Many thanks.

Play framework and gradle

I would like to build the play framework with Gradle in a multiproject build.
The play application would be one of my gradle subprojects. The controllers in play, will call methods in my other gradle projects.
Gradle uses sbt by default. Should I just use sbt command line calls in the gradle build file? And if I do that, would I be able to package it as an application (e.g. a jar file)?
Native support for play is currently in the works for Gradle. This is still in development, but you can take a look at some sample projects in the samples/play directory of the 'all' distribution of Gradle 2.3.

how does gradle wrapper saves form installing gradle if it uses it's build file?

I'n newbie to gradle and I saw this paragraph:
The Gradle Wrapper is the preferred way of starting a Gradle build. It consists of a batch script for Windows support and a shell script for support on OS X and Linux. These scripts allow you to run a Gradle build without requiring that Gradle be installed on your system. You can install the wrapper into your project by adding the following lines to the build.gradle
but I enabled the gradle warpper in the build.gradle that is used only after installing gradle. no?
how do you run once without installing gradle? I run it when adding
task wrapper(type: Wrapper) {
gradleVersion = '1.11'
}
to the build.gradle file. No?
Once gradle wrapper has been run once (which does require another Gradle installation) or the wrapper files have been copied over from another build, and the wrapper files have been committed to source control, all users can (and should) execute the build via the generated gradlew(.bat) script, which will automatically download Gradle on the first invocation. This will ensure that:
Gradle doesn't have to be installed manually
Everybody is using the exact same Gradle version, as required by the build
It's trivial to upgrade everybody to a newer Gradle version (e.g. by editing and committing gradle/wrapper/gradle-wrapper.properties)

Gradle Java debugging project in IntelliJ IDEA

I've used previously maven 3 and it was easy to run anything from IntelliJ IDEA 13, be at main classes or tests - it worked through maven settings. But now I am trying to debug my java project in IDEA with Gradle 1.11. The problem is that idea now creates /out/* directory and trying to run my classes from there instead of using gradle settings and build setups - I mean, with maven I could debug my java project by this:
Set debug configurations
Run it under debug
2 step will call maven install and will run my java project from target/classes/ directory
But with gradle project idea not uses gradle structure.
How can I debug my java project right from IDEA IDE with gradle?
P.S. I can run gradle test under debug in IDEA and it works perfectly, but I need something like gradle debug or gradle run to set breakpoint in IDE, run my Main class and launch my java application through IDE. Hope it is clear what I want to do.
Problem was solved by using application plugin of gradle.
In build.gradle we need to apply this plugin by adding line:
apply plugin: 'application'
And setup main class name:
mainClassName = "Main"
(Main is my main class).
After that in IDEA we need to create configuration to run gradle's run-task and run it under debug.
But if you have a distribution plugin applied to in your project they will conflict. You need to delete the line of applying distribution plugin and any section of this plugin like distributions {...
Application plugin information

Categories

Resources