aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes mvn command problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "mvn command problem" Watch "mvn command problem" New topic
Author

mvn command problem

Hengki Widjaja
Ranch Hand

Joined: Oct 31, 2011
Posts: 44
I've been having a headache with maven. I already know how to transfer using the <outputDirectory>. but how do I set the other dirs such as webapp and resources? I want separate dirs for each of them. how do I do this? thanks
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

A little more details would be helpful.

When you say "<outputDirectory>", which one are you talking about? There are many. Knowing which plugin you are using would be helpful.

What do you mean by "how do I set the other dirs such as webapp and resources"? Set them for what?

It might also help if you described what it is that you hope to accomplish. I suspect that you are wanting to use the Resource plugin to copy files from various locations, but if that is what you want to do, then given the locations you mentioned (webapps, resources) you are doing it wrong!


JBoss In Action
Hengki Widjaja
Ranch Hand

Joined: Oct 31, 2011
Posts: 44
Sorry, perhaps I wasn't too clear. This is my config


I omit the dependencies part since they're too long and irrelevant to my question. when I use compile goal, the files are properly complied and moved to the expected dir. But I also have folder for layout, style, images and various other folders. I want maven to copy/replace these folders to different locations within /test. how do I do this. but please tell me about this plugin you mentioned. I don't see any plugin in my config. thanks
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

As I suspect, you are doing things fundamentally wrong:
a) Your Java source is in the wrong location (it should be in src/main/java)
b) I suspect that your static web files are also in the wrong location (they should be in src/main/webapp)
c) I suspect that you have the wrong packaging type (it should be "war")
d) You should never compile into a Tomcat directory. There are other plugins, such as Cargo, that will deploy apps for you.

You need to look up some tutorials on creating WAR projects with Maven.
Hengki Widjaja
Ranch Hand

Joined: Oct 31, 2011
Posts: 44
Yes, I'm just getting started with maven. must I use war packaging? I prefer deploying it in folder structures (not packaged into one big war file) so if I need to replace a file, I don't need to send the entire war file to my client. Just the necessary files. Is this correct? thanks
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Have you tried using war packaging? Have you noticed what Maven does when you do so? I am tempted to tell you, but I think that you need to try it for yourself. After you run the build (mvn package), closely examine the target directory and tell me what you see.

Important points:
* a Maven build never modifies anything in the "src" directory.
* all "built" artifacts go into the "target" directory
* this does involve a lot of file copying, especially for static web resources, but it does facilitate filtering those static resources
* the "packaging" value describes not just the final artifact type, but also defines the directory structure and the steps used to build the project.

Also, you might be interested in looking at some of the options provided by the War plugin:
http://maven.apache.org/plugins/maven-war-plugin/

And some excellent reading:
Better Builds With Maven: http://www.maestrodev.com/support
Maven: The Complete Reference: http://www.sonatype.com/index.php/Support/Books/Maven-The-Complete-Reference
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: mvn command problem