Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij-idea adding maven plugin

How to add maven plugin in intellij-idea? I want to fast generate something like this:

<build>
    <plugins>
        <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>8.1.16.v20140903</version>
            <configuration>
                <stopKey>STOP</stopKey>
                <stopPort>8089</stopPort>
            </configuration>
        </plugin>
    </plugins>
</build>
like image 283
Dimon Avatar asked Apr 19 '15 08:04

Dimon


1 Answers

  1. Add the Maven Integration plugin in Preferences->Plugins.
  2. Use File->Import Project to select an existing POM at the root of the project. If you don't have one yet, there are ways to have IDEA create it for you.
  3. Use type completion (ctrl-space) while typing in your POM to complete the elements as you type them.
  4. When IDEA asks if you want to import the changes, respond affirmatively.

There are also tricks for having the POM automatically updated as you change project preferences, but I don't think they are as versatile or powerful. Using your example, IDEA is able to configure the IDE when it sees the JUnit plugin reference, but has a harder time generating the plugin reference after configuring unit tests in the IDE.

In general, the power of Maven in the IDE is it provides a declarative (non-procedural) means to have a wide variety of IDEs configured automatically. The Maven POM forms the conduit between the IDEs in that manner.

like image 111
Brian Topping Avatar answered Jan 02 '23 07:01

Brian Topping