Skip to content

Commit

Permalink
Migrate digitalassetlinks project from solana-pay-android-sample to s…
Browse files Browse the repository at this point in the history
…tandalone repository
  • Loading branch information
sdlaver committed Jul 9, 2022
1 parent 39711b3 commit 556a90a
Show file tree
Hide file tree
Showing 28 changed files with 2,988 additions and 0 deletions.
96 changes: 96 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Android CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
release:
types: [ published ]

jobs:
build:
runs-on: ubuntu-latest

steps:
# Setup
- uses: actions/checkout@v3
with:
submodules: true
- name: set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
cache: gradle

# Build
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle and run tests
run: ./gradlew build

# Upload libraries to workflow artifacts
- uses: actions/upload-artifact@v3
if: ${{ github.event_name != 'pull_request' }}
with:
name: libraries
path: digitalassetlinks/build/outputs/aar/*.aar
if-no-files-found: error
retention-days: 5

# Upload javadoc to workflow artifacts
- uses: actions/upload-artifact@v3
if: ${{ github.event_name != 'pull_request' }}
with:
name: digitalassetlinks-javadoc
path: |
digitalassetlinks/build/docs/*
!digitalassetlinks/build/docs/**/*.zip
if-no-files-found: error
retention-days: 1

# Note: only runs on 'push' events
publish-to-gh-pages:
runs-on: ubuntu-latest
needs: build
concurrency: publish-to-gh-pages
if: ${{ github.event_name == 'push' }}

steps:
- name: Update digitalassetlinks javadoc
uses: solana-mobile/gha-commit-artifact-to-branch@v1
with:
token: ${{ secrets.UPDATE_GITHUB_PAGES_TOKEN }}
branch: gh-pages
artifact-name: digitalassetlinks-javadoc
dest: digitalassetlinks
commit-message: 'Update digitalassetlinks javadoc'

# Note: only runs on 'release' events
upload-to-release:
runs-on: ubuntu-latest
needs: build
permissions:
contents: write # needed for uploading files to releases
if: ${{ github.event_name == 'release' }}

steps:
- uses: actions/download-artifact@v3
with:
name: libraries
path: libraries
- uses: actions/download-artifact@v3
with:
name: digitalassetlinks-javadoc
path: digitalassetlinks-javadoc
- name: Compress digitalassetlinks javadoc
run: tar -cvzf digitalassetlinks-javadoc/digitalassetlinks-javadoc.tgz -C digitalassetlinks-javadoc javadoc
- name: Upload files to release
run: gh release -R ${GITHUB_REPOSITORY} upload ${TAG} ${FILES}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ github.event.release.tag_name }}
FILES: |
libraries/*.aar
digitalassetlinks-javadoc/digitalassetlinks-javadoc.tgz
78 changes: 78 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# Built application files
*.apk
*.aar
*.ap_
*.aab

# Files for the ART/Dalvik VM
*.dex

# Java class files
*.class

# Generated files
bin/
gen/
out/
# Uncomment the following line in case you need and you don't have the release build type files in your app
# release/

# Gradle files
.gradle/
build/

# Local configuration file (sdk path, etc)
local.properties

# Proguard folder generated by Eclipse
proguard/

# Log Files
*.log

# Android Studio Navigation editor temp files
.navigation/

# Android Studio captures folder
captures/

# IntelliJ
*.iml
.idea

# Keystore files
# Uncomment the following lines if you do not want to check your keystore files in.
#*.jks
#*.keystore

# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
.cxx/

# Google Services (e.g. APIs or Firebase)
# google-services.json

# Freeline
freeline.py
freeline/
freeline_project_description.json

# fastlane
fastlane/report.xml
fastlane/Preview.html
fastlane/screenshots
fastlane/test_output
fastlane/readme.md

# Version control
vcs.xml

# lint
lint/intermediates/
lint/generated/
lint/outputs/
lint/tmp/
# lint/reports/

# OSX
.DS_Store
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "digitalassetlinks/external/digitalassetlinks"]
path = digitalassetlinks/external/digitalassetlinks
url = https://github.com/google/digitalassetlinks.git
branch = master
14 changes: 14 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright (c) 2022 Solana Mobile Inc.
*/

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'com.android.application' version '7.2.1' apply false
id 'com.android.library' version '7.2.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}

task clean(type: Delete) {
delete rootProject.buildDir
}
1 change: 1 addition & 0 deletions digitalassetlinks/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
100 changes: 100 additions & 0 deletions digitalassetlinks/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/*
* Copyright (c) 2022 Solana Mobile Inc.
*/

plugins {
id 'com.android.library'
id 'com.google.protobuf' version "0.8.19"
}

android {
compileSdk 31

defaultConfig {
minSdk 23
targetSdk 31

consumerProguardFiles "consumer-rules.pro"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

testOptions {
unitTests {
includeAndroidResources = true
}
}

sourceSets {
test {
proto {
srcDir 'external/digitalassetlinks/compatibility-tests/v1'
}
}
}
}

protobuf {
protoc {
def archSuffix = ''
if (osdetector.os == "osx") {
// Workaround: there are no published protoc binaries for Apple Silicon-based macs.
// Apply a manual architecture to the artifact to select the osx-x86_64 variant, which
// runs fine with Rosetta.
archSuffix = ':osx-x86_64'
}
artifact = "com.google.protobuf:protoc:3.21.2$archSuffix" // Download from repositories
}
generateProtoTasks {
all().each { task ->
task.builtins {
java { }
}
}
}
}

// Define JavaDoc build task for all variants
android.libraryVariants.all { variant ->
task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) {
description "Generates Javadoc for $variant.name."
source = variant.javaCompileProvider.get().source
classpath = project.files(android.getBootClasspath().join(File.pathSeparator))
classpath += files(variant.javaCompileProvider.get().classpath)
options.links("https://docs.oracle.com/javase/8/docs/api/");
options.links("https://d.android.com/reference/");
exclude '**/BuildConfig.java'
exclude '**/R.java'
}
}

// Build JavaDoc when making a release build
tasks.whenTaskAdded { task ->
if (task.name == 'assembleRelease') {
task.dependsOn("generateReleaseJavadoc")
}
}

dependencies {
implementation 'androidx.annotation:annotation:1.4.0'
implementation 'androidx.collection:collection:1.2.0'
testImplementation 'com.google.protobuf:protobuf-java:3.21.2'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-inline:4.6.1'
testImplementation 'org.robolectric:robolectric:4.8.1'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'junit:junit:4.13.2'
}
Empty file.
1 change: 1 addition & 0 deletions digitalassetlinks/external/digitalassetlinks
Submodule digitalassetlinks added at d89374
21 changes: 21 additions & 0 deletions digitalassetlinks/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
19 changes: 19 additions & 0 deletions digitalassetlinks/src/androidTest/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (c) 2022 Solana Mobile Inc.
-->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.solana.digitalassetlinks.test">

<!-- Uses internet permissions to fetch Asset Links files from authoritative URLs -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

<!-- Test code requires that we can query some standard Android packages -->
<queries>
<package android:name="com.android.camera2" />
<package android:name="com.google.android.gms" />
</queries>

</manifest>
Loading

0 comments on commit 556a90a

Please sign in to comment.