开发者

Is there a way to use just build command instead of ant build while using ant scripts?

开发者 https://www.devze.com 2023-02-11 07:16 出处:网络
I am using Apache Ant scripts for building a web application. I have written some targets in the build.xml file and the script is running fine. 开发者_如何学JAVAI remember using just \"build\" command

I am using Apache Ant scripts for building a web application. I have written some targets in the build.xml file and the script is running fine. 开发者_如何学JAVAI remember using just "build" command to run ant build instead of "ant build". Can anyone tell me how is that achieved? I was a bit curious on this.


There's no built in "build" command. You could create a simple script file called "build" in the same directory that launched the ant build.

Create a text file with this as the contents:

ant build

In windows save this as a file called build.bat then you can just type build from the command line to start your build.

On unix or linux, save the file as build, then make it executable (with chmod +x build). You'll need to type ./build to get it to run.

I don't think there's a lot of value doing this to replace the simple case of ant build, but if you have to regularly run a build that has multiple targets, or need to pass in certain system variables then it could come in useful.


Maybe your are remembering typing "ant" instead of "ant build" in the past. This is possible to setup. You just need to set default attribute on the root project element in your Ant script to the name of the target you want invoked when an explicit target isn't specified.

For instance...

<project name="myproj" default="build">
  ... 
</project>
0

精彩评论

暂无评论...
验证码 换一张
取 消