Intellij-idea adding maven plugin
63,334
Solution 1
- Add the Maven Integration plugin in Preferences->Plugins.
- 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.
- Use type completion (ctrl-space) while typing in your POM to complete the elements as you type them.
- 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.
Solution 2
- Navigate to your
pom.xml
. - From the
Code
menu, selectGenerate
. - Select
Plugin Template
and enter a search term for the plugin you need.
Comments
-
Dimon about 3 years
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>
-
Davos almost 7 yearsThanks for this, so merely having that Maven Integration plugin, and editing the POM is enough to install plugins? That's super easy. It sounds silly to people who already know, but the docs talk about 'configuring' plugins and it's kind of confusing when I assumed that I would need to d/l and install them. It seems a bit chicken & egg that the build system also builds it's own plugins, but also pretty cool. That's proper dogfooding. Or have I misunderstood?