Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Checkout from CVS using Maven

 
Ronnie D'costa
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Newbie to Maven...

I am developing a tool that uses Maven for project management.
I am reading a file which has the details about the project that needs to be checked out from the CVS.

I am aware about the scm plugin for Maven. Since, I will be getting the project at runtime, I am not sure how to use this information in the POM.xml

Also, is it possible to run a sub-project independently from within a project.

Appreciate all your cooments

Thanks,
Scoucers
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Scoucers,

Can you please change your name in accordance with our naming policy. Thanks!
[ December 05, 2008: Message edited by: Martijn Verburg ]
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Right, now onto your question(s)

1.) I'm not really sure what you're trying to achieve here. Are you calling Maven from a Java program? Are you just having trouble configuring the SCM plugin?

2.) Maven has a concept of a parent pom which can contain several modules, that may be the project/subproject relationship you're looking for.
 
Ronnie D'costa
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Martijn...

My issue is:

Part 1:
I currently have a project developed in Maven. Now I want to run tests from another project : say 'X'(name of this project would be available at runtime). In order to run tests from the project 'X', I need to check it out from the CVS. How can I achieve this using Maven or using JAVA code.

Part 2:
After downloading this project 'X'; how can I redirect the Maven to execute the tests from this project.

Please pour in your vital inputs on this
 
Amit Ghorpade
Bartender
Posts: 2854
10
Fedora Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Ronnie" please include a valid last name(no initials) as mentioned in the naming policy.
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I guess you can simply get your 2nd project to call maven from the command line.
 
Ronnie D'costa
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Martijn,

Thanks for your suggestion.

It seems I am not clear with my explanation about the problem.

As mentioned earlier; I will be downloading the project at runtime.
The project will be downloaded in one of the directories within my current project (may be src/main/java/project). Now I want to run the downloaded project which has its own build files (in case of ANT) and POM file (in case of Maven) from my current project.

At first place, is this possible to execute all together a nes project from within an existing project??? If yes... how to do that???

Regards,
Abhijit
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By downloading the project at runtime do you mean from a Java program or from a Maven Project?

e.g. do you do this:

cd \project1
mvn scm:checkout
# This downloads project2 into project 1 e.g \project1\project2
# You want to automatically run the pom.xml in project2
 
Ronnie D'costa
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Martijn,

You are near to understanding my problem

This is what exactly happens:
I start with execution of project1 (say in directory C:\MyProjects\project1). During its execution it finds the download path of project2. It now checks out the project2 from CVS (at C:\MyProjects\project2). At this point, I want to execute the project2 (I simply have run the 'mvn test' command in the project2) directory.

Currently I am trying to run the 'mvn test' command using the 'getRuntime.exec()' method in java.

FYI ... I am able to run the project2 from the command line. I just need to know the way to execute it via 'getRuntime.exec()'.

If possible, can anyone provide./direct me to an example of this.

Waiting desperately for this one

Ronnie
 
Edwin Stephens
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ronnie,

Perhaps this code will help you execute maven via the runtime exec? It calls the mvn.bat file in maven's bin directory (this is for execution on Windows), calling the test phase of the maven lifecycle. (Note that maven's bin directory needs to be on your path.) It executes on the "myproject2" project, which is located at C:\myworkspace\myproject2.





Hope that helps,
Edwin
 
Ronnie D'costa
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Edwin...

Thanks a lot man ... it really works !!!

Another way I found was the use of ProcessBuilder (for JDK1.5 and above)...
This is the next thing to the Runtime.exec

have a look at this example...



Wish you a Happy & Prosperous New Year!!!
 
Martijn Verburg
author
Bartender
Posts: 3275
5
Eclipse IDE Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ronnie, thanks for sharing your solution!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic