• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

mvn command problem

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Hengki Widjaja
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic