File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Shell script -Automating Maven Builds- Conditional execution if connected to specified network

 
Duran Harris
Ranch Hand
Posts: 608
Eclipse IDE Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I am trying to write a script to assist me with maven builds and deployment.

Right now what I would like is a way to determine whether I am connected to a specific wireless network. What I would like is if I am connected to the network at my workplace, then I would like to export a variable like $CONNECTED.
Then when I invoke maven, I know that I should not specify the --offline argument.

I am a new linux user, what is a fairly easy way to accomplish this ?
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
39
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, I do most of my Maven builds offline and only do a connected build about once a day (manually), since that's enough to keep up with the public repositories. Of course, Your Mileage May Vary if you're pulling in modules from internal projects. And if those projects publish a nightly snapshot or change during the day.

TCP/IP is designed to be able to have network-dependent apps totally independent of what network(s) the machine is plugged into and of which network interface(s) are being used. But if your intent is simply to see if you have access to a private repo, you can "ping" it. Probably the best way to do that is to attempt to "wget" one of the repo's files. If that operation fails, you're offline as far as the Maven build is concerned.

Or, if it's really critical, just forget about the offline option, since Maven will attempt to operate without the remote repositories if it cannot talk to them. It's slower, since Maven is going to keep hoping for a connection, but that way Maven handles network issues with a minimum of fuss.
 
Duran Harris
Ranch Hand
Posts: 608
Eclipse IDE Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim,

I think I will just leave it in offline mode as you say.... and thanks for shedding some light on maven's behaviour when it can't connect to repositories... I was wondering why it didn't fail when it couldn't find a repository and --offline was not specified.
 
Pradeep Kumar
Ranch Hand
Posts: 108
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Duran,
I would love to hear the motive behind writing the scripts to build and deploy using a shell script when you can use a continuos integration tools like hudson/Jenkins . Its so easy for building and managing the complete project build and deployment infrastructure.

http://www.unixonthego.com
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic