Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to run a project using maven

 
Vani Shastri
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
I am new to maven. I have a few doubts -

1. where does the local repository get created once maven is installed?
2. The directory structure like src,main,target etc... do they get created automatically. i mean where are the artifacts placed? do we have to create the structure explicitly?
3. how to customize the settings.xml n how to run a sample project on maven?

help needed.

Thanks.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18156
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not a Maven maven, but a number of popular project types come with a prototype option so you can use Maven to build a blank project with the appropriate deirectory structures and files. I actually made a prototype myself for JSF/Facelet/JPA/Hibernate webapp projects. The process is fairly simple and it's documented on the maven.apache.org site.

Config info is kept in a per-user config directory whose name depends on what version of Maven you're using.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. The local repositorygets created in the %USER_HOME%/.m2 directory by default, though this can be configured to go to another location.

2. In general, no - Maven creates the directory structure for you when you create a Maven project through the archetype plugin.

3. As for the settings.xml - Reference to Maven's settings.xml. As for the second part of this question - that's a big topic - I'd agree with Tim that you should probably look at some projects that already use Maven and see how they do things.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18156
53
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Archetype" is the Maven term I was thinking of when I said "prototype project".

You can see the use of an archetype in the 5-minute getting started guide:
http://maven.apache.org/guides/getting-started/maven-in-five-minutes.html

For custom archetypes, see http://maven.apache.org/guides/introduction/introduction-to-archetypes.html
 
Vani Shastri
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for guiding me.

While running the command for creating the archetype -

mvn archetype:create -DgroupId=com.mycompany.app -DartifactId=my-app

initially the error said - no archetype plugin found. I copied the archetype plugin into the lib folder of maven. Now the error says -

Internal error in the plugin manager executing goal 'org.apache.maven.plugins:maven-archetype-plugin:1.0-alpha-3:create': Cannot find Plexus container for plugin: org.apache.maven.plugins:maven-archetype-plugin

where do i find plexus container?
 
Simon Joseph Aquilina
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

if you have an internet connection on, then maven should download all the plugins you need automatically! If this is not happening, then I sugest you connect to the internet and try that command again! If it still does not work then maybe the remote repository has been labeled as not accessable! What I did for this is delete the repository folder in the .m2 folder, make sure you are connected to the internet, and try that command again!

Regards,
Sim085
 
Vani Shastri
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i copied the plexus containers from the maven site. Still, m getting the same error.
 
Vani Shastri
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the plexus container issue is still not resolved...
the steps i followed -
1. unzip maven
2. set the JAVA_HOME variable to the JDK
3. set the PATH variable to the maven's bin
4. execute mvn --version, to see the version which is in use
5. create a project -
mvn archetype:create -DgroupId=com.demo.app -DartifactId=my-app

At this step, i get an error - The plugin 'org.apache.maven.plugins:maven-archetype-plugin' does not exist or no valid version could be found.

I downloaded archetype plugin explicitly....now the error says - plexus container not found in the plugin. I even downloaded plexus container jars. Still the error exist.
I am connected to the internet for maven to download plugins during run time for all the operations.

Where am i going wrong?
 
Vani Shastri
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my local repository is not getting created? does unzipping maven itself create a local rep .m2?
any settings to be done in settings.xml?
 
Vani Shastri
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I got it....it was with my settings.xml - proxy settings.
Thanks to all for guiding me.
 
Murali Mohan Atmakuri
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

Could you please let me know how you resolved it because i am facing the same problem.

Thanks,
Murali
 
Arundhathi Menon
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vani,

I have changed the settings.xml to have the right proxy and have configured the mirror as well.

My error is -

[WARNING] *** CHECKSUM FAILED - Checksum failed on download: local = 'ea866874c9
68b794a16d61f6a2f8351273e30e66'; remote = 'b0280b2e376542c692104f38b14a4892e509a
379' - IGNORING
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] The PluginDescriptor for the plugin Plugin [org.apache.maven.plugins:mave
n-archetype-plugin] was not found.
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.IllegalStateException: The PluginDescriptor for the plugin Plugin [org
.apache.maven.plugins:maven-archetype-plugin] was not found.
at org.apache.maven.plugin.DefaultPluginManager.addPlugin(DefaultPluginM
anager.java:317)


Can you please help

Regards
Menon
 
barron logan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vani,

What exactly was the problem with your proxy settings....
Can you expand on how you resolved this. I am having the same issue.
 
Arundhathi Menon
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The problem was because the internet policy in our company was obstructing the download of the jars. So when maven runs , it tries updating the respo and fails.

Check with your network administrator, if you are getting the same problem even after the proxy settings are right.

regards
Menon
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
DontWakeTheZombies

(Although I guess following up a year and a half later might help somebody.)
 
Arundhathi Menon
Ranch Hand
Posts: 113
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes David

Was going through the old Maven posts and realised I had not posted the solution. Its a very common prob and this might come into some use for someone!

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic