Lets say I have two maven projects: moduleA and moduleB.
moduleA has a d开发者_开发问答ependency to moduleB in it's pom.xml.
I use IntelliJ Idea, and I have 'Maven Projects' tool window, where I have both these maven projects.
And it is possible to run maven plugin goals from there: I open 'Maven Projects' -> moduleA -> Plugins -> jetty -> jetty:run. Java is run, moduleB is in classpath, but it is in the Maven local repository!
So that, if I change something in moduleB sources and execute jetty:run from Idea, I will not see code changes until moduleB is installed with mvn install.
Is there any solution in Idea to deal without mvn install, for instance to run somehow maven goals with idea-module classpath?
I suggest to use Jetty Integration IDEA plugin to run standalone jetty http://github.com/codebrewer/intellij-idea-jetty-integration-plugin
if you still want to use jetty:run, you could tell IDEA to do mvn install for moduleB: Run -> Edit Configurations -> select youy maven run config -> Configuration tab -> Before launch (at the bottom) -> Run Maven Goal
That IDEA plugin is not developed anymore because IntelliJ now includes its own Jetty runconfig thing.
Here's what worked for me with a Maven multi-module project: In File, Project Structure, Modules I have all modules compile to the same output path ("Use module compile output path"). I chose the "...WEB-INF\classes" path within the folder of the Jetty Deployment folder. Then I also have to tell IDEA to not clear output directories when compiling. Otherwise each module that compiles (one after another) clears the classes from the previous one. Settings, Compiler, uncheck "Clear output directory on rebuild".
Also, I had to put all my external (maven) dependency jars into the "...WEB-INF\lib" folder initially.
Yes, it's hacky, but works. If someone has a better, cleaner solution I'd be interested to know.
精彩评论