aspose file tools*
The moose likes Linux / UNIX and the fly likes Shell script -Automating Maven Builds- Conditional execution if connected to specified network Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Shell script -Automating Maven Builds- Conditional execution if connected to specified network" Watch "Shell script -Automating Maven Builds- Conditional execution if connected to specified network" New topic
Author

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

Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

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 ?


===>SCJP 1.5(72%)<===
==>SCWCD1.5(76%)<===
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15665
    
  15

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Duran Harris
Ranch Hand

Joined: Nov 09, 2008
Posts: 598

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

Joined: Sep 08, 2006
Posts: 108
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


Thanks and Regards, Pradeep Kumar
SCJP 1.6, SCWCD 5.0
 
wood burning stoves
 
subject: Shell script -Automating Maven Builds- Conditional execution if connected to specified network
 
Similar Threads
Autonomate Build and Release Process...
Maven and CruiseControl
IDE vs text editors for coding
How to put configuration files of Spring, JPA and log4j outside jar in standalone app?
Book For Maven