eclipse gradle workspace resolution between gradle projects not working

北城余情 提交于 2019-12-23 10:28:22

问题


2 gradle projects, A and B where A has compile dependency on B defined. Remappig of JARs is enabled for maven & gradle projects. I've tried with custom tooling model enabled and disabled. I have local repositories defined in a file under init.d directory.

Question 1: Why do I get an error of undersolved dependency for project B while resolving dependencies for A? Even though B isn't deployed to any of the repositories local workspace resolution should kick in and resolve it in same way as it is for maven projects (that works btw).

Question 2: Does B need to have anything special apart from group and version defined in build.gradle to be visible for workspace resolution?

I am running with eclipse 4.4.1 and Gradle IDE 3.7.0.201503301651-CI-B39. I've also tried stable release with same eclipse version.

When running with --debug I can see gradle trying to resolve from local repositories and than giving up?


回答1:


The answer to both your question boils down to the fact that there is no workspace resolution as you might know it from maven / m2e.

The 'remapping' of dependencies does not 'resolve' projects in the workspace in the sense that it treats the workspace as some kind of a repository.

Instead dependencies are resolved as normally by Gradle from whatever repositories you have defined in your build scripts. Then the tooling will attempt to determine if some of the resolved jar dependencies correspond to projects in your workspace. It then 'replaces' (or 'remaps') the jar dependency with a project dependency.

So, this means that you must at least publish the jar to some place where it can be resolved before the remapping can kick in. (From that point on you do not have to republish your jars as it doesn't really matter that the resolved jar isn't 'up-to-date')

Some other things that may be useful to know...

  • remapping is only applied to tooling managed dependencies, so you must have 'dependency management' enabled.

  • There's a bug that makes this not work for 'flat file' repo. There could be other cases affected by similar bugs. You should report such bugs if you run into them. (Allthough I didn't have much luck myself getting the Gradle folk's attention about the flatfile bug)



来源:https://stackoverflow.com/questions/29532878/eclipse-gradle-workspace-resolution-between-gradle-projects-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!