How to get list of all JARs dependent by a Gradle app project? - scala

Given a Java or Scala application built using Gradle and dependencies defined by Gradle, is it possible to create a task that simply generates a list of all JARs (with versions in file name) that are dependent by the app and required to run the application?

add 'project-report' plugin will add tasks for dependency report generation html/txt
https://docs.gradle.org/current/userguide/project_report_plugin.html

Related

IntelliJ Scala maven build jar not generating class files

I have created spark scala(version 2.11) application and try to build using maven(version-3) using IntelliJ. At first time,able to compile and built the jar using maven successfully and able to test spark application using jar on cluster as well.Next time,I have modified some of the existing scala class code and tried to build again, code compiled and generate jar file successfully without any issues but there are no scala classes in latest jar file.I would like to know why maven build is not generating class file when I build.Can you please let me know what could be the problem and how Can I fix it ?
The easiest way to build scala applications for spark is to use SBT and fat jar plugin. Details were already described there:
How to build an Uber JAR (Fat JAR) using SBT within IntelliJ IDEA?
Just don't forget to exclude spark jars from fat jar with provided.

Gradle scala project on intellij

How do we create a new gradle project with scala ? For a maven scala project we had the help of archtypes. What is the similar technique when I change my build script into gradle so that I can get a readymade project structure to go ahead and add my scala files into the project without adding src folders etc.
You can leverage the build init plugin for this: gradle init --type scala-library
This will create a project in the current directory, setup the Gradle wrapper and generate basic build files.

View Gradle dependency tree in Eclipse

Is it possible to visualize the dependency tree from inside of Eclipse (e.g. the output of gradle dependencies)? Expanding the Gradle Dependencies tree in Eclipse is a flat view and does not show dependencies for other projects (e.g. if I have a dependency compile project(':project2'), none of project2's dependencies are shown).
Based on this it looks like a tree view is not supported?
Basically I'm looking for the equivalent of this in the maven plugin:
At the time of writing, neither Spring Eclipse Integration Gradle nor Buildship provide a Dependency Hierarchy view we know from m2e.
I don't know when this has been implemented but you can do a gradle dependencies either on command-line or via Buildship Gradle Tasks view within Eclipse. This prints a nice dependency tree of your project's dependencies to the console.
Use gradle 'project-report' plugin to generate report in HTML format.
https://docs.gradle.org/current/userguide/project_report_plugin.html
Add plugin in your build.gradle file:
apply plugin: 'project-report'
And generate report using:
> gradle htmlDependencyReport
For me, it was simply one command
in build.gradle add plugin
apply plugin: 'project-report'
and then go to cmd and run following command
./gradlew htmlDependencyReport
This give me a HTML report WOW Html report 💕
Or if you want the report in a txt file, to make search easy use following command
gradlew dependencyReport
That's all my lord.

Gradle project.sourceSets.main.runtimeClasspath always blank

I'm writing a Gradle plugin to generate Java code from WSDL. Problem is, my task does not find the Java class I'm trying to execute and blows up at runtime with a ClassNotFoundException even though the necessary jar is listed as a compile dependency. I'm using project.sourceSets.main.runtimeClasspath but have tried compileClasspath, adding a build script section to the build file, using configurations.runtime, all to no avail. Note that my project has no Java src code, just Groovy.
Any ideas? The task, a unit test and the build file can be found here:
https://gist.github.com/abhijitsarkar/8432347
c.f.: cross posted on the Gradle forum
It turns out that because my plugin uses project.sourceSets.main.runtimeClasspath, the client needs to declare the dependencies with runtime scope. It is not enough to have the dependencies declared in the plugin project only.

Can JetGradle Be Used In IntelliJ 12 Alongside Gradle Generated Project Files That Have Scala Facets?

I've been trying to make the switch to IntelliJ and Gradle for the Java/Scala projects at my company. From the command line Gradle has been great but I've run into a problem when using Gradle with IntelliJ and projects with Scala facets.
I've tried importing projects in both ways and the only one I've been able to get Scala facets working is to run:
gradle idea
using the Gradle IDEA plugin. After that all I need to do it open the ipr file for the project and the projects work fine.
However, there are some Gradle tasks that I would like to run from within IntelliJ for various things (code generation being the biggest one). I would like to be able to use JetGradle to run those tasks. The problem is when I link the Gradle project to JetGradle, the dependencies in each project break the Scala facet's compiler settings.
It's a multi-module project. Here is the build.gradle for the parent:
allprojects {
apply plugin: 'idea'
version = '1.0'
group = 'company-x'
repositories {
mavenCentral()
}
}
And here's the build.gradle for the scala modules:
apply plugin: 'scala'
dependencies {
compile 'org.scala-lang:scala-library:2.10.1',
'org.scala-lang:scala-reflect:2.10.1',
'org.scala-lang:scala-compiler:2.10.1',
'org.slf4j:slf4j-log4j12:1.7.2',
'com.typesafe.akka:akka-actor_2.10:2.1.4'
testCompile 'junit:junit:4.8.1',
'org.scalatest:scalatest:1.2'
}
Before linking the project to JetGradle the Scala facet is setup with a library called 'scala-compiler-2.10.1' that contains the Scala compiler, library, and reflect jars and src. After linking the project, the project libraries are replaced with all of the Gradle project dependencies. The Scala facet then gives the error:
Compiler library: no scala-library*.jar found
When I look at the libraries again, there is still a library called 'scala-compiler-2.10.1' but it's only the compiler. The library and reflect jars are now separated out.
Has anyone out there figured out how to get the Scala facet and JetGradle to play nicely with one another?
From this IntelliJ blog (Better Gradle Support in IntelliJ IDEA 12.1) it seems JetGradle is not ready to support Scala.
I'm waiting for IntelliJ 13.x and stick to Maven for the time being.