aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Maven - Not able to locate source folder and hence not building the source file 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 "Maven - Not able to locate source folder and hence not building the source file" Watch "Maven - Not able to locate source folder and hence not building the source file" New topic
Author

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

Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 244
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


Success is not doing extraordinary things but doing ordinary things extraordinarily well.
Saif Asif
Ranch Hand

Joined: Aug 11, 2011
Posts: 440

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 ?


Muhammad Saif Asif Mirza
OCJA(5/6) OCJP(6) OCJWCD(6)
Saurabh Agrawal
Ranch Hand

Joined: Oct 07, 2003
Posts: 244
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

Joined: Oct 07, 2003
Posts: 244
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

Joined: Jun 25, 2001
Posts: 16145
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Maven - Not able to locate source folder and hence not building the source file