Eclipse like Classpath container concept

Hi everyone,

I am brand new to IntelliJ - well this is not exactly true, I once used it in the early 2000s.
Eclipse provides dynamically computed classpaths using so called "classpath containers".

Is there something similar in IntelliJ so that one can implement a plug-in that provides missing dependencies to the classpath of active modules in the IDE?
The idea is that one must not have opened the complete transitive clousure of dependency modules in the IDE. Missing modules/libraries are retrieved from
the server and the classpath is computed dynamically per module.

Thanks in advance for every hint and best regards

Udo

6 comments
Comment actions Permalink

IntelliJ IDEA does not have such a concept. To solve your problem in IntelliJ IDEA, you can provide a custom run configuration type that will download the libraries and add them to the classpath before running the program. See, for example, this code:
https://github.com/JetBrains/intellij-plugins/blob/master/osmorc/src/org/osmorc/run/OsgiRunState.java#L115

0
Comment actions Permalink

Hi Dmitry,

thanks for your reply and the link, I will check it out!
Hmm sad, sad. It's not so much about running a program with the right classpath.
The point is this: We have web applications divided into several modules.
We use the term "module" as well for our server side components so that a web business application is for example divided into a web module, a domain module, some library modules providing apache commons for example, a jdbc module providing  jdbc drivers and a spring module providing the spring frameworks etc.
Now you can check out the modules you want to change in the IDE - in Eclipse as a project and in IntelliJ as a module.
If you want to work on the domain logic for example you just check out the domain module from SVN or Git. But now the IDE will report the missing dependencies as errors, so that you are forced to check out all other modules as well.
The alternative is that a plug-in computes the dependencies, detects the missing modules and provides them to the domain module's classpath. This is what our existing plug-in does using Eclipse classpath containers.

Is it possible to just add a root folder to a modules classpath that contains a whole bunch of JARs, so that I could write a plug-in that fills this root folder with all the JARs and IntelliJ will find the missing dependencies once the JARs are there?

Best regards
Udo

0
Comment actions Permalink

First of all, how large is your project? It may not be worth bothering at all - at JetBrains, we work with the entire IntelliJ IDEA source code (500+ modules) as a single project and don't experience any significant issues with that.

Adding a folder with a bunch of jars is possible: simply press the + button in the Dependencies tab, select "Jars or directories..." and point to a directory with jar files.

0
Comment actions Permalink

It's not one project, there can be more.
The whole thing is called z2-environment and it is a Java live cycle environment on top of jetty. It's a different way to develop and run Java web business solutions without the need for a build infrastructure and deployment of WARs or EARs. The server runtime pulls the sources by itself from the source repository and compiles them on demand. Yes that's true! The Java server is directly connected to the SVN or Git repositories and "sees" the same module structure that you see in the IDE.
You can checkout http://redmine.z2-environment.net/projects/z2-environment/wiki if you want to read more about it.

Usually business applications are only a few modules. But the whole z2 basis and 3rd party module can be 20-30 modules or so. Most of the time you are working on the business modules. So you have only these 3-4 modules in your IDE.
The rest is provided as JARs via the classpath container.
But once in a while you need the basis modules (e.g. for debugging purposes). You check out those 2-3 modules you need and ask the classpath container to recompute the dependencies. Now the missing dependencies are provided as module references to the active modules in the IDE (plus JARs for those modules which are still not available in the IDE).
When working in a team in happens that team members add new modules when the solution is growing. Other team members must not import then into their IDE. They just ask the classpath container to recompute the dependencies and get the new modules as compiled JARs.
Since the server "knows" the sources and compiles them by izself it has a deep understanding of the module structure and can easily answer questions like "what dependencies does module A has?" or "please give me the compiled JARs for module X, Y and Z".

Sorry now I complete switched the topic ;-)

I will try the folder approach - maybe we'll don't get the full feature we have in Eclipse but - we'll see.
Thanks again for your help :-)

Best Regards
udo

0
Comment actions Permalink

Hi Dmitry,

is it possible to change the .iml file via a plug-in so that it contains module references to existing modules and JAR entries to (downloaded) JARs for non existing references?
I tried to edit the iml file manually and IDEA detects the changes and reacts accordingly. So one could rewrite the .iml files via a plug-in...
Well this is a hack of course but would you classify this as a "pragmatic" or as a "by no means" hack?

Best regards
Udo

0
Comment actions Permalink

You don't need to modify the .iml file direcly; instead, you can use IntelliJ IDEA's project model APIs to make the changes you need. The starting point for the API is ModuleRootManager.getModifiableModel(). You can find plenty of usage examples in the IntelliJ Community Edition source code.

0

Please sign in to leave a comment.