Get Spring boot source code when using Gradle - java

I'm using gradle for dependency management of my Spring boot project. I want to be able to debug through the source of Spring classes.
Is there a way to tell gradle to download the source along the jar files?
Update 1
I add classifier: 'sources' to the gradle properties file:
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version:'1.5.8.RELEASE', classifier: 'sources'
In eclipse I refreshed the gradle project, but I still get Source not found error when I want to debug inside the spring source code.
Update 2
I added the following to the gradle properties file:
apply plugin: 'java'
apply plugin: 'eclipse'
eclipse {
classpath {
downloadJavadoc = true
downloadSources = true
}
}
and ran gradle cleanEclipse eclipse, but still I cannot debug inside the spring source.

Related

How to build Spring Statemachine with maven

I downloaded Spring Statemachine (ZIP)
I don't have any a pom.xml/maven instruction
In [site] the maven link isn't available https://github.com/spring-projects/spring-framework/wiki/Downloading-Spring-artifacts
for Maven repository information.
How should I build project with maven ?
Its gradle project.. You can make use of gradle to build it.
Gradle to Maven:
Add Maven plugin in the build.gradle file.
build.gradle should look like this:
apply plugin: 'java'
apply plugin: 'maven'
group = 'com.abc.app'
// artifactId is taken by default, from folder name
version = '0.1-SNAPSHOT'
dependencies {
compile 'commons-lang:commons-lang:2.3'
}
Run gradle install in the directory containing build.gradle will do the job.
It will create pom-default.xml in the build/poms subfolder.
Reference links for Gradle Build:
https://guides.gradle.org/creating-new-gradle-builds/
https://www.eclipse.org/community/eclipse_newsletter/2018/february/buildship.php
https://spring.io/guides/gs/gradle/
https://www.jetbrains.com/help/idea/gradle.html

Add parameter to a Gradle plugin

I'm new to Gradle and I'm working on a Liferay project. I'm trying to use the Liferay javadoc gradle plugin without success. I'm working on the Liferay IDE (Eclipse) and I already have the javadoc task available to execute. The problem is, after the excution (which completes successfully) I can't find the created docs.
I read the documentation which says there is destinationDir property but I'm unable to set it using Gradle.
I tried following this SO question in order to create a custom Gradle task but without success.
How can I set the destinationDir in order to get the generated docs?
Edit:
The (automatic generated) settings.gradle is:
buildscript {
dependencies {
classpath group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "1.5.0"
classpath group: "net.saliman", name: "gradle-properties-plugin", version: "1.4.6"
}
repositories {
maven {
url "https://cdn.lfrs.sl/repository.liferay.com/nexus/content/groups/public"
}
}
}
apply plugin: "net.saliman.properties"
apply plugin: "com.liferay.workspace"
I'm pretty sure that com.liferay.gradle.plugins.workspace includes the javadoc plugin. Furthermore, Liferay also automatically creates an empty build.gradle where I put:
apply plugin: 'java'
task api(type: Javadoc) {
source = sourceSets.main.allJava
destinationDir = new File(buildDir, "/api")
}
Launching the api Gradle task the javadoc plugin is not executed

How to setup a Java Gradle plugin project in IntelliJ?

I'm having issues setting up a Java Gradle Plugin project for IntelliJ.
Specifically, I can't get the Java to import the required gradle library.
import org.gradle.api.Plugin;
import org.gradle.api.Project;
I found the answer for Groovy and ported it over for Java.
Insure you have gradle downloaded, and the gradle bin directory added to your path.
Create a new directory for your project to exist in. Open up command prompt, and run the following command:
gradle init --type java-library
Then edit the generated build.gradle file and add the following the the dependencies:
compile gradleApi()
Also and the following:
apply plugin: 'idea'
This should result in a build.gradle that looks like:
// Apply the java plugin to add support for Java
apply plugin: 'java'
apply plugin: 'idea'
// In this section you declare where to find the dependencies of your project
repositories {
// Use jcenter for resolving your dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
dependencies {
compile gradleApi()
// The production code uses Guava
compile 'com.google.guava:guava:20.0'
// Use JUnit test framework
testCompile 'junit:junit:4.12'
}
Then back in command prompt, run:
gradlew idea
And open the generated project in IntelliJ
Groovy Source: How to setup a Gradle plugin project in IntelliJ?

Which is the proper Gradle plugin to support 'provided' method?

I'm currently trying to include Project Lombok helper into my Gradle project, but while following their instructions for Gradle within my build.gradle, I'm getting the following error:
Error:(11, 0) Build script error, unsupported Gradle DSL method found: 'provided()'!
Possible causes could be:
you are using Gradle version where the method is absent
you didn't apply Gradle plugin which provides the method
or there is a mistake in a build script
My current build.gradle file:
apply plugin: 'java'
sourceCompatibility = 1.5
version = '1.0'
repositories {
mavenCentral()
}
dependencies {
provided "org.projectlombok:lombok:1.14.4"
testCompile group: 'junit', name: 'junit', version: '4.11'
}
As of release 2.12, provided scope is called compileOnly
Old answer:
Provided scope is available in 'war' plugin (http://www.gradle.org/docs/current/userguide/war_plugin.html , providedCompile ) If You don't want to use the 'war' plugin, there is also an opened JIRA issue regarding 'provided' scope http://issues.gradle.org/browse/GRADLE-784 , suggested workaround is to create Your own cofiguration:
configurations {
provided
}
and set it to be used with your compilation classpath:
sourceSets {
main {
compileClasspath += configurations.provided
}
}
Check your app level gradle file. If any line looks like this:
compile dependency.gson provided dependency.javaxAnnotation
Edit it like this:
compile dependency.gson
provided dependency.javaxAnnotation
It should work.

Why do xml configs of gradle dependencies go with "Gradle__" prefix? Intellij IDEA 13

Java Spring project with Gradle 1.9 and vertx. Local gradle distribution.
Some lines of build.gradle
apply plugin 'java'
apply plugin 'groovy'
apply plugin 'idea'
buildscript {
repositories {
jcenter()
}
}
repositories {
mavenCentral()
}
dependencies {
...
compile 'org.springframework:spring-context-support:3.2.5.RELEASE'
compile 'org.springframework:spring-aop:3.2.5.RELEASE'
compile 'org.springframework:spring-aspects:3.2.5.RELEASE'
...
}
I have an existing gradle project downloaded from git with xml configs in .idea/libraries folder named spring-aop_3_2_5_RELEASE.xml, for example, where we can find xml tag <library name="spring-aop-3.2.5.RELEASE">...</library>.
After I had imported this project new file Gradle__spring-aop_3_2_5_RELEASE.xml appeared with only difference in name attribute of the library tag: Gradle: spring-aop-3.2.5.RELEASE. So i have duplicate xml configs for dependencies. I wonder why my gradle added that prefix.
The prefix is hardcoded, IDEA 13 needs a reimport of your old Gradle projects that were created in IDEA 12. It's not obvious, but there will be a notification about it in the next update.
In the Gradle generated project you can exclude the library files from the version control, same for the .iml files that can be also ignored when using Maven. Other files can be still shared (like code style, run configurations, inspection profiles, etc). Check this document for details.

Categories

Resources