Difference between revisions of "Graddle build process"

From Agility
Jump to: navigation, search
(Created page with "1. Configuration Gradle builds can be executed in two ways, by installing gradle or by using gradleWrapper (tool which automatically downloads gradle in correct version) Reco...")
 
(2. Building and releasing from command prompt)
 
(32 intermediate revisions by the same user not shown)
Line 1: Line 1:
1. Configuration  
+
== 1. Configuration ==
Gradle builds can be executed in two ways, by installing gradle or by using gradleWrapper (tool which automatically downloads gradle in correct version)
+
Gradle builds can be executed in two ways, by installing gradle or by using gradleWrapper (tool which automatically downloads gradle in correct version)<br />
Recommended approach:
+
'''Recommended approach:'''<br />
Find JDK Installation Directory. Open the default installation path for the JDK:
+
Find JDK Installation Directory. <br />
C:\Program Files\Java
+
Open the default installation path for the JDK:<br />
There should be a subdirectory like:
+
C:\Program Files\Java<br />
C:\Program Files\Java\jdk1.6.0_10  
+
There should be a subdirectory like:<br />
Set the JAVA_HOME Variable
+
C:\Program Files\Java\jdk1.6.0_10 <br />
Once you have the JDK installation path:
+
Set the JAVA_HOME Variable<br />
1. Right-click the My Computer icon on your desktop and select Properties.
+
Once you have the JDK installation path:<br />
2. Click the Advanced tab, then click the Environment Variables button.
+
*1. Right-click the My Computer icon on your desktop and select Properties.
3. Under System Variables, click New.
+
*2. Click the Advanced tab, then click the Environment Variables button.
4. Enter the variable name as JAVA_HOME.
+
*3. Under System Variables, click New.<br />
5. Enter the variable value as the installation path for the Java Development Kit.
+
*4. Enter the variable name as JAVA_HOME.
6. Click OK.
+
*5. Enter the variable value as the installation path for the Java Development Kit.
7. Click edit on PATH variable
+
*6. Click OK.
8. Click NEW
+
*7. Click edit on PATH variable
9. Enter : %JAVA_HOME%/bin
+
*8. Click NEW
10. Click OK
+
*9. Enter : C:\Program Files\Java\jdk1.6.0_10
11. Click Apply Changes.
+
*10. Click OK
 +
*11. Click Apply Changes.
 +
*12.    You need to have Android SDK installed, simplest way is to download Android Studio 2.3 and install it (Android Studio to c:\Android\Studio, SDK to c:\Android\SDK).
 +
https://developer.android.com/studio/index.html#win-bundle[https://developer.android.com/studio/index.html#win-bundle]
 +
*13.    After Android Studio install, please set ANDROID_HOME env. variable to dir you have SDK installed (eq. ANDROID_HOME=c:\Android\SDK the same procedure as JAVA_HOME Variable )
 +
You need to run Android studio and agree to software license before using 'gradle'
  
Not Recommended approach  
+
== Not Recommended approach ==
Install gradle according to this article:
+
Install gradle according to this article:<br />
https://docs.gradle.org/current/userguide/userguide_single.html#sec:prerequisites
+
https://docs.gradle.org/current/userguide/userguide_single.html#sec:prerequisites<br />
NOTE: If you choose not recommended approach, then instead of gradlew command use gradle command for every example in this guide.
+
NOTE: If you choose not recommended approach, then instead of gradlew command use gradle command for every example in this guide. <br />
 
 
2. Building and releasing from command prompt
 
  
1. Download project from SVN
+
== 2. Building and releasing from command prompt ==
2. Open command prompt and go to project directory
+
3. Execute one of the following commands to build project:
+
Commands
+
All commands starts with gradlew keyword.
+
Commands to build the project :
+
1. assemble<Variant Name>
+
2. assemble<Build Type Name>
+
3. assemble<Product Flavor Name>
+
#1 allows directly building a single variant. For instance assembleFlavor1Debug.
+
#2 allows building all APKs for a given Build Type. For instance assembleDebug will build both Flavor1Debug and Flavor2Debug variants.
+
#3 allows building all APKs for a given flavor. For instance assembleFlavor1 will build both Flavor1Debug and Flavor1Release variants.
+
The task assemble will build all possible variants.
+
Flavors Build Types
+
RAM Release
+
PCH Debug
+
FSH
+
standard
+
  
Apks are generated in ./build/outputs/apk folder.
+
*1. Download project from SVN
Command to clean all generated files:
+
*2. Open command prompt and go to project directory
 +
*3. Execute one of the following commands to build project:
 +
Commands <br />
 +
All commands starts with gradlew keyword.<br />
 +
Commands to build the project :<br />
 +
*1. assemble<Variant Name>
 +
*2. assemble<Build Type Name>
 +
*3. assemble<Product Flavor Name>
 +
*- allows directly building a single variant. For instance assembleFlavor1Debug.
 +
*- allows building all APKs for a given Build Type. For instance assembleDebug will build both Flavor1Debug and Flavor2Debug variants.
 +
*- allows building all APKs for a given flavor. For instance assembleFlavor1 will build both Flavor1Debug and Flavor1Release variants.
 +
The task assemble will build all possible variants:<br />
 +
{|
 +
|'''Flavors'''|| '''Build Types'''
 +
|-
 +
|RAM|| Release
 +
|-
 +
|PCH|| Debug
 +
|-
 +
|FSH||
 +
|-
 +
|standard ||
 +
|}
 +
 
 +
Apks are generated in ./build/outputs/apk folder.<br />
 +
Command to clean all generated files:<br />
 
1. clean
 
1. clean
For all commands use gradlew --help
+
For all commands use gradlew --help<br />
Parameters
+
Parameters<br />
There are two parameters that can be passed to building script:
+
There are two parameters that can be passed to building script:<br />
• projVersion – version of the project i.e 7.2.19
+
• projVersion – version of the project i.e 7.2.19<br />
• hotfixnumber – hotfix number  have to be lower than 10
+
• hotfixnumber – hotfix number  have to be lower than 10<br />
To pass parameter use –P operator i.e  -Photfixnumber=4  
+
To pass parameter use –P operator i.e  -Photfixnumber=4 <br />
Examples:
+
Examples:<br />
  
gradlew assembleRelease -PprojVersion=7.2.19 : generate signed apks in versionName 7.2.19 and versionCode:702190 for all clients
+
'''gradlew assembleRelease -PprojVersion=7.2.19''' : generate signed apks in versionName 7.2.19 and versionCode:702190 for all clients<br />
gradlew assembleRelease -PprojVersion=7.2.19 -Photfixnumber=4  : generate signed apks in versionName 7.2.19 and versionCode:702194 for all clients
+
'''gradlew assembleRelease -PprojVersion=7.2.19 -Photfixnumber=4''' : generate signed apks in versionName 7.2.19 and versionCode:702194 for all clients<br />
gradlew assemblePCHRelease : generate signed apk for PCH in default version
+
'''gradlew assemblePCHRelease''' : generate signed apk for PCH in default version<br />
gradlew assemblePCHDebug : generate debugable apk for PCH in default version
+
'''gradlew assemblePCHDebug''' : generate debugable apk for PCH in default version<br />
gradlew assemblePCH : generate debugable and signed apk for PCH in default version
+
'''gradlew assemblePCH''' : generate debugable and signed apk for PCH in default version<br />
gradlew assemblePCH : generate debugable apks for all clients in default version
+
'''gradlew assemblePCH''' : generate debugable apks for all clients in default version<br />
  
Tips
+
Tips<br />
Commands can be shorten as long as they remain unique.
+
Commands can be shorten as long as they remain unique.<br />
gradlew assemblePCHRelease can be shorten to gradlew aPCHR
+
gradlew assemblePCHRelease can be shorten to gradlew aPCHR<br />

Latest revision as of 14:50, 4 April 2017

1. Configuration

Gradle builds can be executed in two ways, by installing gradle or by using gradleWrapper (tool which automatically downloads gradle in correct version)
Recommended approach:
Find JDK Installation Directory.
Open the default installation path for the JDK:
C:\Program Files\Java
There should be a subdirectory like:
C:\Program Files\Java\jdk1.6.0_10
Set the JAVA_HOME Variable
Once you have the JDK installation path:

  • 1. Right-click the My Computer icon on your desktop and select Properties.
  • 2. Click the Advanced tab, then click the Environment Variables button.
  • 3. Under System Variables, click New.
  • 4. Enter the variable name as JAVA_HOME.
  • 5. Enter the variable value as the installation path for the Java Development Kit.
  • 6. Click OK.
  • 7. Click edit on PATH variable
  • 8. Click NEW
  • 9. Enter : C:\Program Files\Java\jdk1.6.0_10
  • 10. Click OK
  • 11. Click Apply Changes.
  • 12. You need to have Android SDK installed, simplest way is to download Android Studio 2.3 and install it (Android Studio to c:\Android\Studio, SDK to c:\Android\SDK).

https://developer.android.com/studio/index.html#win-bundle[1]

  • 13. After Android Studio install, please set ANDROID_HOME env. variable to dir you have SDK installed (eq. ANDROID_HOME=c:\Android\SDK the same procedure as JAVA_HOME Variable )

You need to run Android studio and agree to software license before using 'gradle'

Not Recommended approach

Install gradle according to this article:
https://docs.gradle.org/current/userguide/userguide_single.html#sec:prerequisites
NOTE: If you choose not recommended approach, then instead of gradlew command use gradle command for every example in this guide.

2. Building and releasing from command prompt

  • 1. Download project from SVN
  • 2. Open command prompt and go to project directory
  • 3. Execute one of the following commands to build project:

Commands
All commands starts with gradlew keyword.
Commands to build the project :

  • 1. assemble<Variant Name>
  • 2. assemble<Build Type Name>
  • 3. assemble<Product Flavor Name>
  • - allows directly building a single variant. For instance assembleFlavor1Debug.
  • - allows building all APKs for a given Build Type. For instance assembleDebug will build both Flavor1Debug and Flavor2Debug variants.
  • - allows building all APKs for a given flavor. For instance assembleFlavor1 will build both Flavor1Debug and Flavor1Release variants.

The task assemble will build all possible variants:

Flavors Build Types
RAM Release
PCH Debug
FSH
standard

Apks are generated in ./build/outputs/apk folder.
Command to clean all generated files:
1. clean For all commands use gradlew --help
Parameters
There are two parameters that can be passed to building script:
• projVersion – version of the project i.e 7.2.19
• hotfixnumber – hotfix number have to be lower than 10
To pass parameter use –P operator i.e -Photfixnumber=4
Examples:

gradlew assembleRelease -PprojVersion=7.2.19 : generate signed apks in versionName 7.2.19 and versionCode:702190 for all clients
gradlew assembleRelease -PprojVersion=7.2.19 -Photfixnumber=4  : generate signed apks in versionName 7.2.19 and versionCode:702194 for all clients
gradlew assemblePCHRelease : generate signed apk for PCH in default version
gradlew assemblePCHDebug : generate debugable apk for PCH in default version
gradlew assemblePCH : generate debugable and signed apk for PCH in default version
gradlew assemblePCH : generate debugable apks for all clients in default version

Tips
Commands can be shorten as long as they remain unique.
gradlew assemblePCHRelease can be shorten to gradlew aPCHR