📜 ⬆️ ⬇️

Create a workspace for IntelliJ IDEA from the project maven

A long time ago I worked in a big company, we wrote JEE applications. Then there was IntelliJ IDEA 4.0. One of the projects consisted of approximately 30 modules. Creating a workspace from scratch took a lot of time, so workspace was stored in svn. Someone was sitting on IDEA 4.0, someone was on IDEA 5.0, and when someone komitil their iml'ki and ipr'ki in svn, others were terribly angry because their personal settings flew, so everyone There was a personal work space, and new programmers suffered from a non-working svn.

Then maven and maven-idea-plugin appeared, it became possible to create a work space from the maven project. Then came the Maven Integration plugin: the integration of mavena and IDEA, it became possible to immediately open a maven project.

In early 2010, I had a couple of projects with about 20 modules each, and I spent a little time setting them up. Now I have 20 projects, each with about 50 modules, each project has several brunches and tags. It was very difficult to create and switch between workspaces. It was also difficult for other programmers, they also spent a lot of time on creating and configuring workspaces. There was a feeling that programmers were doing nothing at all.

If you used maven-idea-plugin to create a workspace, then you had to do the work space after it as follows:
1. Put the encoding UTF-8
2. Put a tick "Transparent native-to-ascii conversation"
3. Add Redmine to Issue Navigation
4. Put the right "Project JDK"
5. Put the desired "Project language level"
6. Add a volume to the “Run Configuration”, specify start parameters, specify a web module
7. In the web artifact, specify the “Output directory” which coincides with that of Mavenow.
8. Select the “Javac in-process (Java6 + only)” compiler.
')
If the Maven Intergration plugin was used, then you had to do the same thing, plus creating a web artifact with your hands. I had a record: the configuration of workspace in 10 minutes. It seems a little, but every time I got tired of doing all these actions very quickly.

The latest version of the maven-idea-plugin from repo1.maven.org dates back to August 2008. The source code of this plugin is as much Hindu as there is no desire to write a patch. There was a desire to do everything in their own way: so that it would not slow down, be expandable, so that the code would be read, so that everyone would finally stop wasting time on creating workspaces.

For two days off, a maven-idea-plugin was written and posted on Google Code. The name is the same to run as "mvn idea: idea" and easily remembered.

Pluses of the new plugin:
1. By default, the plugin does not download the source. Previously, after “mvn idea: idea”, you had to wait a long time on those libraries that do not have source codes, and if you run “mvn idea: idea -DdownloadSources = false”, then the sources will not connect at all in the spacespace. Now the sources are always connected in the workspace, but they download only if you explicitly say "mvn idea: idea -DdownloadSources = true"

2. The plugin does not require compiled libraries in the local repository. Previously, to assemble the workspace, it was necessary to build the project through the “mvn clean install”, it took about 10 more minutes.

3. And most importantly, the plugin allows you to create workspaces that you don’t need to do later. Now there are exactly 20 parameters. Learn more at http://code.google.com/p/maven-idea-plugin/wiki/HowToInstall

To connect a plugin, you need to specify in its main pom.xml plugin configuration and repository:

 <build>
     <plugins>
         <plugin>
             <groupId> com.googlecode </ groupId>
             <artifactId> maven-idea-plugin </ artifactId>
             <version> 1.3 </ version>
         </ plugin>
     </ plugins>
 </ build>

 <pluginRepositories>
     <pluginRepository>
         <id> maven-idea-plugin-repo </ id>
         <url> http://maven-idea-plugin.googlecode.com/svn/maven-repo </ url>
     </ pluginRepository>
 </ pluginRepositories>

If a war-packaging module is encountered among the modules, a web-artifact, and a tomkat-configuration will be automatically added. The tomkata server itself must be added in advance; this is the global IDEA configuration. After opening the workspace, you can immediately start tomkat. Many parameters, such as the server name or JDK name, are set by default, but you can change them in the plugin configuration:

 <plugin>
     <groupId> com.googlecode </ groupId>
     <artifactId> maven-idea-plugin </ artifactId>
     <version> 1.3 </ version>
     <configuration>
         <applicationServerTitle> My Web Application </ applicationServerTitle>
         <openInBrowser> true </ openInBrowser>
         <openInBrowserUrl> http://127.0.0.1/app?page=MyList </ openInBrowserUrl>
         <reformatCodeBeforeCommit> true </ reformatCodeBeforeCommit>
     </ configuration>
 </ plugin>

With this configuration of the plug-in, the required server name will be in the tomkat-configuration, after launching the application, the browser will open, during the commit there will automatically be a check mark for formatting the code and, of course, the 8 points indicated at the beginning will be made.

The purpose of the plug-in is to make it so as not to waste time on setting up IDEA: I made a check of the required brunch, launched “mvn idea: idea”, clicked on launching tomkata and that's it.

Source: https://habr.com/ru/post/110187/


All Articles