Migrating from Eclipse - about projects and modules

已回答

I read the migration FAQ (https://www.jetbrains.com/help/idea/migrating-from-eclipse-to-intellij-idea.html) but it does not have much detail about how to migrate workspaces and projects.  It just states that an Eclipse workspace becomes an IDEA Project and that an Eclipse Project becomes an IDEA Module.

So... how to migrate becomes very confusing.  Perhaps somebody can here can clarify and give advice.

This is our current Eclipse environment:

  • We build with Maven, each Eclipse project generating a library JAR, a deployable JAR with embedded Tomcat 9 or a WAR that get deployed on a Tomcat 9 server.
  • We have one workspace, dozens of projects. This is perfect for our troubleshooting and changes as it allows us to do global searches and changes across many Eclipse projects quickly.

So, since according to the FAQ "eclipse workspace" = "IDEA project" and "eclipse project" = "IDEA module", in principle it sounds like the migration should be simple:  Make one "IDEA project" to contain everything and then make one "IDEA module" for each Eclipse project, each with its own POM.

But the moment I go to create the new project it already seems to break.  I could name the IDEA project "workspace", select Java, Maven and the Java 17 version that we use, but the model breaks at the point of selecting the Group ID and artifact ID... since the artifact ID belongs to the module (eclipse project) and not the project (eclipse workspace).

It seems that I am either completely misunderstanding the migration equivalence, or that perhaps I need to make one IDEA project per Eclipse project... but in that case things would likely break at build/execute since I don't see any way to tell a project that it needs to launch other projects (like REST services) that it depends on ahead of its own launch so that they will be present.

Since my situation is probably more the norm than the exception for people migrating from Eclipse, the only conclusion I can reach is that I am completely misunderstanding the migration FAQ.

Can somebody please help me understand what is it that I am misinterpreting and how to actually migrate?

 

0

I could name the IDEA project "workspace", select Java, Maven and the Java 17 version that we use, but the model breaks at the point of selecting the Group ID and artifact ID... since the artifact ID belongs to the module (eclipse project) and not the project (eclipse workspace).

IntelliJ IDEA automatically detects Eclipse projects located on your computer and places them in the dedicated node right on the Welcome screen. This node will be available among the recent projects until you decide to remove it. When the Eclipse project is in the node, just click it to quickly open it in the IDE.

Does it help if you click on Open existing Eclipse projects... and select your workspace?

Alternatively try File | New | Project from Existing Sources in the main menu:

IntelliJ IDEA will convert your workspace to project and your projects to modules inside this project.

0

Thanks, my situation does not seem to be as simple as what you describe but your suggestions do hint at a possible solution.

 

Positive:  There is indeed an "Eclipse Projects" folder (or rather it seems to be identified as a "project group") under Projects.

Negative: The Eclipse Projects folder seems to have collected ALL of the Eclipse workspaces - from all of the independent installs that I have - into the same place.

Theory that I am going to test:

  • If I right-click Eclipse Projects or on one of the projects in that list I see options for "New Project Group" and "Move to Group".  So...
  • I am going to first create a new project group for each Eclipse Workspace and move the projects to their corresponding project groups.
  • After that I will look at what is offered when I am given the option to create a Project from Existing sources for one of the groups.

The above should get me closer to what I need.

 

But I suspect that it might not be all that I need. 

Based on that structure (one project for the Eclipse workspace, and a module for each Eclipse project) I will need to build differently for each type of module:

  • Some modules should compile as JARs that are used by other modules.
  • Some modules should compile as self execting JARs that contain embedded Tomcat.
  • Some modules should compile as WARs that get deployed on Tomcat.
  • And of course I will need to be able to launch one or more of those modules (and supporting Tomcat) in the IDE for testing and troubleshooting.

For clarification of the above, these is how the modules fit together:

  • bom-pom-master (Eclipse project, IDEA module) is the parent to most .POM files.
  • core-lib (Eclipse project, IDEA module) is a common library used by almost all Eclipse projects / IDEA modules.
  • core-services (Eclipse project, IDEA module) is an executable JAR with embedded Tomcat that must be running BEFORE any WARs are started on the Tomcat server that runs almost all of the other Eclipse projects / IDEA modules.
  • ***-api (Eclipse project, IDEA module) are small library JARs included by modules that produce REST service WARs, and also in the modules that call/rely on those rest services.
  • And finally there are a number of modules that produce a .WAR implementing either a REST service or a web application.

 

Obviously I am still not quite clear on how I will achieve the above.  Or even if the Project/Module structure is capable of supporting the "enterprise project/module structure" I describe.  If that were so the key question would be "how do I achieve it with IDEA?"  As IDEA is known to be a better IDE than Eclipse and widely used in complex Enterprise-level environments I am certain that there is a way to do what Eclipse does by default, even if it is not immediately obvious.

0

UPDATE: 

Attempting to import this complex project structure from Eclipse does not quite do what I need.  I am going to create things from scratch in IDEA and migrate the code manually instead.

QUESTION:

For the project structure above, is it better to make one Project with all of the pieces as modules (keep in mind that some of those pieces are full apps in their own), or should it be a 1-1 project conversion from Eclipse?

 

0

In your case you can try the following:

- Create an empty project (e.g workspace in terms of Eclipse) using File | New | Project | Empty Project.

- Once the project is created and opened go to File | Project Structure | Modules and use New Module/Import Module actions to add your Eclipse projects as IDEA modules:

You'll get something like this:

 

1

That seems to work, with all of the Eclipse projects as modules in IntelliJ and when I run the maven install it results in placing the built product into the repository.

That is a major step forward that seems to allow me to reproduce the eclipse build process for my projects in IntelliJ.  I can now proceed to migrating more of my projects and try to run and test inside IntelliJ as my next step.

Thank you for your help!

0

请先登录再写评论。