• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Maven - Not able to locate source folder and hence not building the source file

 
Saurabh Agrawal
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using Maven 3.0 version to build my struts project which has the project hierarchy as follows:

src -> com -> myorg -> source files
webContent

When I am building the project using maven goal - mvn compiler:compile, it says build successful. However, it says no source files available for compilation.

I read that default src directory that maven searches for is src/main/java. However, I don't want to convert my project into maven way of organization as it is a struts 2 guideline of organization.

Is it possible to specify the source folder in the pom.xml. I tried few things but could not make it work.

My pom.xml looks like the following:



Quick help is much appreciated.

Saurabh
 
Saif Asif
Ranch Hand
Posts: 440
Eclipse IDE Hibernate Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read that default src directory that maven searches for is src/main/java. However, I don't want to convert my project into maven way of organization as it is a struts 2 guideline of organization


The default structure that maven follows (and also recommends) is the Standard Directory Structure ( the src/main/java structure ) and you can also create a struts project in this maven directory structure ( you wont face any issue and I have also done multiple struts2 projects following the maven directory layout ) .

How-ever if you still dont want to follow the maven structure ( although I advise you to do so since it will make your life easy ) , then you have the option to configure maven plugins to work according to your structure.


I dont see any issue in this configuration , can you please verify that everything is exactly as you have specified above ?
 
Saurabh Agrawal
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Saif,

Thanks for your reply.

As I mentioned in original post, the directory structure that we have in project is - src/com/panera/*.

In the configuration I posted, I tried giving value as "src" as well as "src/com/panera" but it still doesn't locate the source files.

I tried it again and still the same result.

Saurabh
 
Saurabh Agrawal
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have found the solution myself and would like to share it with the group.

In case we need to have a different source folder structure as opposed to maven project structure, we need to specify the the source directory under build tag in pom.xml as follows:



It will compile the code from the source directory.

Thanks.
Saurabh
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18153
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do consider what Saif recommended, however.

I'm not that fond of Maven's default directory expectations, but I use them for 2 reasons:

1. When I hand off a project (or receive a project) from someone else, I know where things will be and so will they. We may not like where they are, but we won't have to embark on a "treasure hunt" to find them.

2. Not only the compiler makes assumptions about directory structure in the Maven build process, so you may find that occasional additional customizations will be required. Murphy's Law dictates that they will manifest at the most inconvenient times.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic