Is there a way to get depencency tree from idea gradle plugin - intellij-plugin

In maven project, I can get it from MavenProject. throw mavenProject.getDependencyTree(), mavenProject.getDependencies();
Is there a way to get dependency tree in idea gradle plugin.

Related

Intellij Plugin Development - Gradle does not find dependency of IntelliJ

I am currently developing a plugin for IntelliJ and trying to use another built-in IntelliJ Plugin as dependency (git4idea). As described in the IntelliJ Plugin Development documentation, I added the required JARs to my class Path in Project Structure:
Project Structure Dialog Screenshot
I also added <depends>Git4Idea</depends> to my plugin.xml file.
IntelliJ finds these jars now and Code Completion works well, no errors found...
But when I try to build the Plugin with gradle I get ClassNotFound errors or errors like this:
TkGitflowBaseImpl.java:15: error: package git4idea.commands does not exist
import git4idea.commands.Git;
^
Obviously, Gradle does not find these jars. Since they are part of the IntelliJ installation, I can't just add them to a lib folder and add them as local jars in the build.gradle file. As Gradle JVM, I chose the exact same JVM I chose as JVM behind the IDEA Platform SDK, so the jars should be available to Gradle.
Do you know how I can help Gradle find these jars or add them as "provided" dependencies without adding them to a lib folder?
I am using IntelliJ IDEA 2017.2.5 and Gradle 4.2.1
After reading through the documentation of the IntelliJ Gradle Plugin (https://github.com/JetBrains/gradle-intellij-plugin), I saw that that a "=" was missing in the build.gradle file like:
intellij {
version '2017.2.5'
pluginName 'pluginname'
plugins = ['Git4Idea']
}
instead of
intellij {
version '2017.2.5'
pluginName 'pluginname'
plugins ['Git4Idea']
}
https://plugins.jetbrains.com/docs/intellij/plugin-dependencies.html#optional-plugin-dependencies
build.gradle
intellij {
version = '2021.2'
plugins = ['Git4Idea']
}
src\main\resources\META-INF\plugin.xml
<depends>Git4Idea</depends>

IntelliJ downloads Gradle dependencies but cannot find them during compile

IntelliJ downloaded the dependencies listed in my build.gradle file and they show up in the External Library, but IntelliJ fails to find them during compile. It just throws a bunch of "package x does not exist" and "cannot resolve symbol". Under the Project Structure -> Modules -> Dependencies they all show up and are listed as compile.
If I try to build it with Gradle it's successful, so it's just IntelliJ. Any ideas?
If it's important, I'm using this on a Mac.
Found the answer. IntelliJ was treating Main and Test as modules with no dependency related to the project itself and all of the library dependencies were stored at the project level.
I killed off Main and Test as modules and it sorted itself out.

get oozie-client dependency with Gradle build

I'm trying to build my project using IntelliJ and gradle. I have a dependency on oozie-client jar.
I defined the dependency in gradle as follows:
dependencies {
compile 'com.yahoo.oozie:oozie-core:3.0.0'
}
when I run buildDependency I get the following error:
* What went wrong:
Could not resolve all dependencies for configuration ':compile'.
Could not resolve com.yahoo.oozie:oozie-core:3.0.0.
Required by:
:TestRunnerFramework:1.0
Could not resolve com.yahoo.oozie:oozie-core:3.0.0.
Could not parse POM http://repo1.maven.org/maven2/com/yahoo/oozie/oozie-core/3.0.0/oozie-core-3.0.0.pom
Could not find any version that matches com.yahoo.oozie:oozie-main:3.0.0.
please advice,
This is either an incorrect POM (or incorrect parent POM), or a POM that Gradle fails to interpret correctly (there are a few known limitations around this). Often, the only solution is to edit the POM, for example in your binary artifact repository. If you think the problem is on Gradle's side, you can file an issue over at http://forums.gradle.org.

How can I view transitive dependencies of a Maven pom.xml file?

Is there a CLI tool I can use to quickly view the transitive dependencies of a Maven pom.xml file?
On the CLI, use mvn dependency:tree
(Here are some additional Usage notes)
When running dependency:tree on multi-module maven project, use mvn compile dependency:tree instead1.
Otherwise, the POM Editor in M2Eclipse (Maven integration for Eclipse) is very good, and it includes a hierarchical dependency view.
1If you don't compile, you might get error Failed to execute goal on project baseproject: Could not resolve dependencies for project com.company:childproject:jar:1.0.0: Could not find artifact. This might happen because dependency:tree command doesn't build projects and doesn't resolve dependencies, and your projects are not installed in maven repository.

Resolving maven dependencies

Inovking maven2 goal mvn dependency:list on an artifact pom causes to download the whole dependent artifact packages. I think only those pom files are necessary for resolving dependencies. Aren't they?
On the dependecy plugin documentation you can read that dependency:list is an alias for dependency:resolve. What you need is dependency:tree which :
Displays the dependency tree for this project.
Even with dependency:tree you will have to download dependencies.
From Arnaud Héritier (developer on Maven Project)
This is a problem in maven core which doesn't allow in 2.x to resolve dependencies without downloading artifacts.
Each mojo (plug-in in the Apache Maven) has a functionality description. See all dependency plugin functionality.
I am working with the current edition of Maven (the plug-in that shipped with Eclipse Neon), and I'm still working to get my head around how to make it do all the magical things it is claimed to be able to do.
I have the screen pictured below, in which the dependency highlighted in the left pane is unresolved.
!Dependency tree, showing missing dependency1
I thought that selecting (executing) the Update Project item off the project's context menu, as shown in the following image, would resolve it, but it left me with three errors, all, one way or another, the result of a missing dependency.
!Maven fly-out menu in project context menu2
By examining the file system, I have confirmed that the dependency is, in fact, absent.
Color me confused; why didn't that action download the missing dependency?