Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use build pipeline to build android_client apk #445

Merged
merged 20 commits into from
May 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
Expand Down
13 changes: 9 additions & 4 deletions android_client/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId "com.microsoft.hydralab.android.client"
minSdkVersion 21
targetSdkVersion 28
versionCode 17
versionName '2.6.0'
versionCode rootProject.ext.clientVersionCode
versionName rootProject.ext.clientVersionNumber
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
compileOptions {
Expand All @@ -23,12 +23,17 @@ android {

release {
signingConfig signingConfigs.debug
minifyEnabled true
shrinkResources true
minifyEnabled false
TedaLIEz marked this conversation as resolved.
Show resolved Hide resolved
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
namespace 'com.microsoft.hydralab.android.client'

lint {
xmlReport true
abortOnError false
}
}

dependencies {
Expand Down
14 changes: 13 additions & 1 deletion android_client/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@ buildscript {
classpath 'com.android.tools.build:gradle:7.4.2'
}
}

ext {
if (project.hasProperty("clientVersionNumber")) {
clientVersionNumber = project.property("clientVersionNumber")
} else {
clientVersionNumber = '1.0.0-test'
}
if (project.hasProperty("clientVersionCode")) {
clientVersionCode = Integer.parseInt(project.property("clientVersionCode"))
} else {
clientVersionCode = 10000
}
println "version number: " + clientVersionNumber + ", version code: " + clientVersionCode
}
allprojects {
repositories {
google()
Expand Down
Binary file added android_client/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
58 changes: 54 additions & 4 deletions azure-pipelines-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ resources:

variables:
# Container registry service connection established during pipeline creation
version: '$(Build.BuildId)'
# Agent VM image name
vmImageName: 'windows-latest'
fullBuild: $[ne(variables['Build.Reason'], 'PullRequest')]
- name: vmImageName
value: 'windows-latest'
- name: fullBuild
value: $[ne(variables['Build.Reason'], 'PullRequest')]

stages:
- stage: Build
Expand Down Expand Up @@ -61,8 +62,9 @@ stages:
(Get-Content agent/src/main/resources/version.properties) -Replace '0.0.0', $hydraVersion| Set-Content agent/src/main/resources/version.properties
(Get-Content center/src/main/resources/version.properties) -Replace '0.0.0', $hydraVersion| Set-Content center/src/main/resources/version.properties
}
echo "##vso[task.setvariable variable=hydraVersionCode;]$hydraVersionCode"
echo "##vso[task.setvariable variable=hydraVersion;]$hydraVersion"
workingDirectory: '$(Build.Repository.LocalPath)'
condition: eq(variables.fullBuild, 'true')
- task: Gradle@3
displayName: Run JUnit Test
inputs:
Expand Down Expand Up @@ -92,6 +94,38 @@ stages:
summaryFileLocation: 'build/reports/jacoco/jacocoRootReport/*.xml'
reportDirectory: 'build/reports/jacoco/jacocoRootReport/html'
condition: eq(variables.fullBuild, 'false')
- task: Gradle@2
displayName: Package Android client APK
inputs:
workingDirectory: 'android_client'
gradleWrapperFile: 'android_client/gradlew'
tasks: 'assembleRelease'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
options: '-PclientVersionCode=$(hydraVersionCode) -PclientVersionNumber=$(hydraVersion)'
- task: Gradle@2
displayName: Package Android client APK
inputs:
workingDirectory: 'android_client'
gradleWrapperFile: 'android_client/gradlew'
tasks: 'assembleAndroidTest'
publishJUnitResults: false
javaHomeOption: 'JDKVersion'
jdkVersionOption: '1.11'
options: '-PclientVersionCode=$(hydraVersionCode) -PclientVersionNumber=$(hydraVersion)'
- task: PowerShell@2
displayName: Copy APK to folder for deployment
inputs:
targetType: 'inline'
script: |
cp android_client/app/build/outputs/apk/androidTest/debug/app-debug-androidTest.apk common/src/main/resources/record_androidTest.apk -force
- task: PowerShell@2
displayName: Copy APK to folder for deployment
inputs:
targetType: 'inline'
script: |
cp android_client/app/build/outputs/apk/release/app-release.apk common/src/main/resources/record_release.apk -force
- task: Gradle@2
displayName: Build center
inputs:
Expand Down Expand Up @@ -171,6 +205,22 @@ stages:
sonarQubeRunAnalysis: false
spotBugsAnalysis: false
condition: eq(variables.fullBuild, 'true')
- task: PowerShell@2
displayName: Copy APK to artifact
inputs:
targetType: 'inline'
script: |
mkdir -p $(Build.ArtifactStagingDirectory)/android_client
cp android_client/app/build/outputs/apk/release/app-release.apk $(Build.ArtifactStagingDirectory)/android_client/app-release-$hydraVersion.apk
condition: eq(variables.fullBuild, 'true')
- task: PowerShell@2
displayName: Copy Mapping file to artifact
inputs:
targetType: 'inline'
script: |
mkdir -p $(Build.ArtifactStagingDirectory)/android_client
cp android_client/app/build/outputs/mapping/release/mapping.txt $(Build.ArtifactStagingDirectory)/android_client/
condition: eq(variables.fullBuild, 'true')
- task: CopyFiles@2
displayName: Copy agent jar
inputs:
Expand Down
Binary file removed common/src/main/resources/record_androidTest.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class PkgUtilTest extends BaseTest {

@Test
public void analysisApkFile() throws IOException {
File recordFile = new File("src/main/resources/record_release.apk");
File recordFile = new File("src/test/resources/record_release.apk");
JSONObject res = PkgUtil.analysisFile(recordFile, EntityType.APP_FILE_SET);

logger.info(res.toString(SerializerFeature.PrettyFormat));
Expand Down