Skip to content

Commit

Permalink
feat: setup android local/remote dependency retrieval and version number
Browse files Browse the repository at this point in the history
  • Loading branch information
aeddi committed Dec 1, 2019
1 parent 4479da1 commit 334fa13
Show file tree
Hide file tree
Showing 21 changed files with 50 additions and 9 deletions.
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
MAKEFILE_DIR = $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
GO_DIR = $(MAKEFILE_DIR)/go
IOS_DIR = $(MAKEFILE_DIR)/ios
ANDROID_DIR = $(MAKEFILE_DIR)/android
IOS_DIR = $(MAKEFILE_DIR)/ios
GO_SRC = $(shell find $(GO_DIR) -not \( -path $(GO_DIR)/vendor -prune \) -name \*.go)

GOMOBILE = $(GOPATH)/bin/gomobile
GOMOBILE_OPT ?=

VERSION_FILE = $(MAKEFILE_DIR)/version
LIB_VERSION = $(shell cat $(VERSION_FILE))

VENDOR = $(GO_DIR)/vendor
MOD_FILES = $(GO_DIR)/go.mod $(GO_DIR)/go.mod
MOD_FILES = $(GO_DIR)/go.mod $(GO_DIR)/go.sum

BUILD_DIR_IOS = $(IOS_DIR)/Frameworks
BUILD_LIB_IOS = $(BUILD_DIR_IOS)/Mobile.framework
BUILD_DIR_ANDROID = $(GO_DIR)/build/android
BUILD_LIB_ANDROID = $(BUILD_DIR_ANDROID)/ipfs.aar
BUILD_DIR_ANDROID = $(ANDROID_DIR)/local_repo/ipfs/gomobile/gomobile-ipfs/$(LIB_VERSION)
BUILD_LIB_ANDROID = $(BUILD_DIR_ANDROID)/gomobile-ipfs-$(LIB_VERSION).aar
BUILD_POM_ANDROID = $(BUILD_DIR_ANDROID)/gomobile-ipfs-$(LIB_VERSION).pom
POM_TEMPLATE = $(ANDROID_DIR)/pom_template

.PHONY: help build build.android build.ios test deps clean clean.android clean.ios re re.ios re.android

Expand All @@ -23,14 +28,17 @@ help:

build: build.android build.ios

build.android: $(BUILD_LIB_ANDROID)
build.android: $(BUILD_LIB_ANDROID) $(BUILD_POM_ANDROID)

$(BUILD_LIB_ANDROID): $(BUILD_DIR_ANDROID) $(GO_SRC) $(VENDOR) | $(GOMOBILE)
GO111MODULE=off $(GOMOBILE) bind -v $(GOMOBILE_OPT) -target=android -o $(BUILD_LIB_ANDROID) github.com/berty/gomobile-ipfs/go

$(BUILD_DIR_ANDROID):
mkdir -p $(BUILD_DIR_ANDROID)

$(BUILD_POM_ANDROID):
sed -e 's/{{LIB_VERSION}}/$(LIB_VERSION)/g' $(POM_TEMPLATE) > $(BUILD_POM_ANDROID)

build.ios: $(BUILD_LIB_IOS)

$(BUILD_LIB_IOS): $(BUILD_DIR_IOS) $(GO_SRC) $(VENDOR) | $(GOMOBILE)
Expand Down
3 changes: 3 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Created by https://www.gitignore.io/api/android,intellij+iml,gradle

### Android ###
# Local repository
local_repo

# Built application files
*.apk
*.ap_
Expand Down
Binary file modified android/.idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file modified android/.idea/caches/gradle_models.ser
Binary file not shown.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation project(":gomobile-ipfs")
implementation project(':bridge')
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ android {

}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
String libVersion = new File("${rootDir.getPath()}/../version").readLines()[0]

dependencies {
implementation "ipfs.gomobile:gomobile-ipfs:$libVersion"
implementation 'androidx.appcompat:appcompat:1.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 5 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ buildscript {

allprojects {
repositories {
// If gomobile-ipfs is available locally, use it first
maven { url "${rootDir.getPath()}/local_repo" }
// If not available locally, download it from IPFS maven repo
// maven { url "TODO: setup IPFS maven repo" }
google()
jcenter()

}
}


task clean(type: Delete) {
delete rootProject.buildDir
}
Binary file removed android/gomobile-ipfs/libs/ipfs-sources.jar
Binary file not shown.
22 changes: 22 additions & 0 deletions android/pom_template
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>ipfs.gomobile</groupId>
<artifactId>gomobile-ipfs</artifactId>
<version>{{LIB_VERSION}}</version>
<packaging>aar</packaging>
<name>gomobile-ipfs</name>
<description>Gomobile IPFS core (go-ipfs + bridge)</description>
<url>https://github.com/berty/gomobile-ipfs</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
<license>
<name>MIT License</name>
<url>http://www.opensource.org/licenses/mit-license.php</url>
</license>
</licenses>
</project>
2 changes: 1 addition & 1 deletion android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
include ':app', ':gomobile-ipfs'
include ':app', ':bridge'
rootProject.name='GomobileIPFSExample'
2 changes: 2 additions & 0 deletions version
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0.0.1

0 comments on commit 334fa13

Please sign in to comment.