netbeans-gradle-project icon indicating copy to clipboard operation
netbeans-gradle-project copied to clipboard

Pre-load Source or Project before Fetching Dependencies

Open mam0nth opened this issue 11 years ago • 13 comments

Possibility to load first the project upon opening before it fetches or downloads all the defined dependencies.

Scenario:

Open an existing gradle based project. eg. https://github.com/spring-projects/spring-framework

You will notice that upon expanding the Project node you will see

Build Scripts
        -  BuildSrc
        - settings.gradle
        - build.gradle
        - gradle.properties

there are no projects or source folder.

Enhancement:

  • It is good if the project is loaded even the required dependencies is not yet on cache or classpath. If in case it was a multi-project, just use the project name like in Maven plugin as "Modules"
ProjectName
  + Source Packages (Required by default)
  + Resources (Optional)
  + Test Packages (Optional)
  + Test Resources (Optional)
  + Dependencies (Required)
  + Subprojects/Submodules (Optional, show only if it is multi project)
  + Build Scripts

If it is possible to load in demand the Subprojects please do so( Im not sure if this is achievable in Gradle Model)

  • Alignment of the behavior of the project to the existing project type in NetBeans. It is good also if we can provide like in Maven the "Resolved Project Problems" if there was an unresolved or broken dependencies in the project. If the user select the "Resolved Project Problems" that's the time where the plugin fetches the dependencies, and in the notification it will prompt to run a Priming Build. In maven the command executed by NetBeans was mvn -DskipTests=true --fail-at-end --also-make --projects . install, in Gradle I don't have an idea if there was an equivalent for this.

mam0nth avatar Dec 10 '13 02:12 mam0nth

Every time I request something from Gradle, each project gets evaluated. So, if I request source folder hierarchy in a separate step as dependency resolution, I have to evaluate the projects twice which is a considerable overhead.

My current idea is to cache the evaluated projects persistently. So, if a project has ever been loaded, subsequent project loads will be very quick (still project evaluation will continue on the background).

What exactly do you want to do with a semi loaded project? I mean, maybe I can address directly some of your needs.

kelemen avatar Dec 10 '13 08:12 kelemen

Recently, I open Spring Project which have a gradle build system. I just need to check the source code, simply browsing. I just wait so long before the project sources have been loaded. It is downloading first the dependencies, this because of the gradle model, I guess it is need to be a valid gradle model.

Semi loaded or pre-loaded project pertaining only to the structure of the sources, resources including the rendered node for the source files even the imports is not yet resolved. Imagine you just need to open a project without intention of building it, we can add if the user has slow internet connection or no connection at all.

I'm not rushing for this enhancement. I'm aware that we are dealing with performance issue here. As far as I know NetBeans mechanism for handling big project is not to load all the project but it is through "in-demand" loading of project like in maven. We have parent pom where we can see all the sub module or simply modules but we don't need to load or to downloads dependencies upon opening of the project.

mam0nth avatar Dec 10 '13 09:12 mam0nth

In my case, I always run even commandline gradle in offline mode, as I have three upstream repositories, and gradle seems to totally screw up requesting files it ALREADY HAS from one upstream repo from another one which doesn't have them. This slows down project loading HUGELY, and probably annoys the other upstreams. I meant to ask for an offline mode in the plugin to resolve this, as I can always run from the commandline to fetch new dependencies.

shevek avatar Dec 11 '13 14:12 shevek

I assume you need both "Reload project" and "Reload project offline" and let any of them be selected as default in the global settings (for when you open a project). Also, project caching would still help you because background project loading after it could be ignored.

kelemen avatar Dec 11 '13 15:12 kelemen

Let try to load first the project without touching the dependencies - if it is required a valid gradle model, so we need to find another way. In case it is not a valid gradle project, it will loaded the current structure of the project - shows only the build script.

Related to @shevek comment, I would like to add additional scenario, this is when we are using rebasing or checkout another branch especially in Git. I rather want to have that the sources is already available in the Project Exploring than waiting to gradle finished reloading the project inside netbeans. NOTE, we were expecting a huge slowness impact on NetBeans indexing here, even maven suffering on this specially when we have a huge codebase.

mam0nth avatar Dec 12 '13 06:12 mam0nth

When switching branches, do you need to reload the source folders because the script changes (additional source sets are added) or because some source folders did not exist before?

kelemen avatar Dec 12 '13 08:12 kelemen

It could be. For example you are developing a feature, then you add additional dependencies, gradle plugin and additional package then there are instance you need to check in some experimental branch with a different model but you just want to look at java file. Of course you don't want to wait to build the project again - for this it is good to load the sources unless the gradle model is totally broken.

DISCLAIMER: This is only based on observing NetBeans' Maven plugin since it has same functionality.

mam0nth avatar Dec 12 '13 09:12 mam0nth

The original request (opening without depenendencies), isn't trivial to solve without caveats but adding different kinds reloads might be more feasible. For example, "Reload sources only", "Reload offline". Reloading with "--offline" is rather simple, the only issue is that the global settings page is rather crowded already.

kelemen avatar Dec 12 '13 09:12 kelemen

So it is possible. I suggest for the global settings is to use "Category" like in Maven so we can avoid the crowded setting. For the layout, I can help :)

mam0nth avatar Dec 12 '13 09:12 mam0nth

Actually, I'm just trying to avoid slow compiles, not slow startups. The compileJava downloads dependencies, and gradle is broken, and tries to download things it already has, and makes 1 minute compile take 10 minutes.

shevek avatar Dec 14 '13 11:12 shevek

Avoiding slow task execution is possible, albeit a little tedious to configure. You should configure all your built-in tasks in the project properties by adding an "--offline" line to the argument list. I'd also create a new profile for it, so you just have to switch profiles to compile with or without "--offline".

kelemen avatar Dec 14 '13 13:12 kelemen

That's a good call, thank you. Also voted for the 'kill build' ticket at gradle.

shevek avatar Dec 14 '13 23:12 shevek

In Maven plug-in, it has this "Dependency Download Strategy". I think we can have this also in issue #105 .

mam0nth avatar Dec 15 '13 06:12 mam0nth