Running batch file after every build in eclipse

I have a number of projects that I am working on simultaneously.

Each time I create and run one of them, apk is located as usual in the bin folder.

If I want to copy this apk to another folder outside the project, I have to do it manually.

I created one batch file that copies all the apk files of my projects to the right place.


Is there a way to change the output location of the bin folder somewhere outside the project, or is it more preferable to run the batch file after each build ?


NOTIFICATION

I am using eclipse with ADT. I tried to add a creator that runs the batch file. However, when the batch file is running, the apk file has not yet been created. I tried all combinations of options in the builder and all possible sequences of collectors.

+6
source share
2 answers

If you are happy to use Eclipse while you are improving the build, then go to the command line for the final build, and then using Ant it is very easy to get what you want with very little effort or customization.

Assumptions

1) . Your sources are in the Android workspace, and in the end you will get two sets of binary files: one made by Eclipse, the other made by Ant, will be outside the workspace, as set by the PROPERTIES file

2) You are using SDK14 or 15 (Ant changed to 14)

3) You have Ant installed and in your path - you need to have Ant 1.8.2 - this is not the one used by Eclipse, you may have to get it from the Apache website, it’s easy to install

Steps

1) Make a sample project from the command line, as described in http://developer.android.com/guide/developing/projects/projects-cmdline.html

For example, I used: android create project --target 8 --name Sample15App --path c: \ dev \ projects \ samples \ Sample15 - Sample15Activity --package com.me.samplefifteen

This will create a directory and some files that you will use later as a template in your projects.

2) Create a sample project in your workspace from Eclipse, I made an EclipseSample in one of my workspaces

3) Copy the following files from Sample15App to the root of your EclipseSample project:

build.xml ant.properties local.properties

4) Modify ant.properties (which is initially empty) to look like:

projectname=EclipseSample workspace.dir=/dev/projects/EclipseIndigo/AndroidWorkTwo base.dir=${workspace.dir}/${projectname} outbasebase.dir=/dev/projects/AntBuilds outbase.dir=${outbasebase.dir}/${projectname} ant.project.name=${projectname} out.dir=${outbase.dir}/bin layout.dir=${base.dir}/res/layout source.dir=${base.dir}/src 

From this you can see that my workspace is / dev / projects / EclipseIndigo / AndroidWorkTwo

The eclipse project below it is in the EclipseSample directory

I want my apks to fall into / dev / projects / AntBuilds / EclipseSample (i.e. outbasebase combined with the project name - so for other projects you can use a very similar ant.properties change projectname file)

5) IMPORTANT - CHANGE build.xml file

Comment or delete the line:

 <project name="Sample15App" default="help"> 

just replace it

 <project> 

It just means that it will take the project name from ant.properties, not build.xml, and you can use the same build.xml in all your projects, only ant.properties needs to be changed

6) try with "ant debug" to build debug apks in / dev / projects / AntBuilds / EclipseSample

7) Finally, if you want to automate the assembly of the release (signing and entering the password automatically), add lines, for example

 key.store.password=YourPassword key.alias.password=YourPassword key.store=c:/users/you/yourrelease-key.keystore key.alias=release_alias 

in ant.properties and then just type "ant release"

If you do not add them, he will tell you what you are signing manually, and since no password entries were found in 'build.properties' (it was what ant.properties was called pre SDK 14, they should have fixed it!)

+5
source

You can add new builders to your project using Project Properties->Builders->New...

One way to do this is to create an ant construct (which copies the file) or just a plain old script or batch file.

+4
source

Source: https://habr.com/ru/post/901801/


All Articles