aspose file tools*
The moose likes Ant, Maven and Other Build Tools and the fly likes Deployment with Ant 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 "Deployment with Ant" Watch "Deployment with Ant" New topic
Author

Deployment with Ant

Kanika Sud
Greenhorn

Joined: May 09, 2011
Posts: 21
Hi.

Presently, the project I am working on is in exploded archive form. I want to use the build script method of deployment. I want to know if its possible to rename a file after deploying to remote server as in:

deploy db.properties_stage as db.properties

Hope I am able to convey the idea.

Thanks.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

The answer is "maybe". Are you renaming the file by hand? That is, via a command line using the mv or rename command (depending on your OS). Or are you wantting to do this on Ant? And if in Ant, as part of the deploy step or after the deploy step? And exactly how does your "deploy" step work? Are you using a specific Ant task for that? (I won't go into asking whether the app can handle the new name I assume that it can).

Perhaps you should post the target that does the "deploy"...


JBoss In Action
Kanika Sud
Greenhorn

Joined: May 09, 2011
Posts: 21
Hi Peter,

In fact I'm totally new to build scripts. I'm still trying to find my way about them. But the requirement is simple:
Two files exist on my local system:

db_stage.properties
db_prd.properties

The names were different because the stage and production servers will take different properties but the same file name: db.properties

Hence the need to rename on the remote server. As long as the renaming happens on the remote server, I don't think it should make a difference before after, right?

Thanks,
Kanika.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

As long as the rename happens before you start up the server it should not matter. You can manually rename it. Or you can have a script rename it. It doesn't matter.

I face the same situation in my projects. When we release our product, it requires a specific set of properties to work with the rest of the application suite. But for development, I need a different set of properties that match my development environment. We use Maven for builds. We have only a single source properties file whose contents contain property references. Our Maven pom.xml file defines the properties for the production environment. I have a settings.xml file with a profile that overrides the property references for my dev/test environment. When Jenkins builds my project, it is all set for production, with the correct properties file with the correct values. When I build the project on my PC, it is all configured for my dev.test environment. Thus we never have to edit or rename anything. (Before I got hold of the projects and converted the team used both a dual properties file scheme like you are using, and a properties.template scheme, both of which required manual intervention before doing any build, and both of which required additional work to prevent the developer-specific modifications from ending up in source control. Maven profiles eliminated all of that manual work and make the builds more repeatable and consistent.)
Kanika Sud
Greenhorn

Joined: May 09, 2011
Posts: 21
Hi Peter,

Thank you so much. That was very helpful. I guess I'll have to make that suggestion to my Project Lead here!
 
jQuery in Action, 2nd edition
 
subject: Deployment with Ant