Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Fork of Requery Android with MAX_VARIABLE_NUMBER=32768 #2

Merged
merged 3 commits into from
Feb 14, 2020
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
63 changes: 63 additions & 0 deletions DeployJenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!groovy

// This file is named DeployJenkins file, so that it won't get picked up by the main PlanGrid Jenkins project

/**
* Devtools team created PlangridStage groovy function uses env.GIT_BRANCH and env.PROJECT_NAME
* Need to set these variables prior to use PlangridStage
* (https://github.com/plangrid/plangrid-build-tools/blob/dev/vars/PlangridStage.groovy)
*/
env.GIT_BRANCH = env.BRANCH_NAME
env.PROJECT_NAME = 'sqlite-android'

def deploy_project = env.DEPLOY_PROJECT


throttle(['BigMem']) {
node() {

deploy_build_dir = 'build'

stage("SCM") {
checkout scm

sh("git checkout origin/${DEPLOY_BRANCH}")
sh("git clean -fdx")

env.GIT_COMMIT = sh(returnStdout: true, script: "git rev-parse HEAD").trim()

if (!env.DOCKER_IMAGE_BASE) {
env.DOCKER_IMAGE_BASE = "${env.PROJECT_NAME}:${env.GIT_COMMIT}"
}
}

stage('Build Docker') {
retry(2) {
sh '/opt/plangrid/build-tools/bin/build-docker'
}
CURRENT_DIR = sh(returnStdout: true, script: "pwd").trim()

DOCKER_ID = sh(returnStdout: true, script: "docker run \
-e BRANCH_NAME=${env.BRANCH_NAME} \
-e BUILD_NUMBER=${env.BUILD_NUMBER} \
-e JENKINS_URL=${env.JENKINS_URL} \
-e CHANGE_URL=${env.CHANGE_URL} \
-e CHANGE_ID=${env.CHANGE_ID} \
-e ARTIFACTORY_USER \
-e ARTIFACTORY_PASSWORD \
-itd \
-v /var/lib/jenkins/gradlecache:/gradle_home/caches/ \
-v " + "${CURRENT_DIR}:/build " + "${env.PROJECT_NAME}:${env.GIT_COMMIT}").trim()
}

stage('Clean') {
sh("docker exec ${DOCKER_ID} bash -c 'find \${GRADLE_USER_HOME}/caches -type f -name \"*.lock\" | xargs -I {} rm \"{}\"'")
}
stage("Build") {
sh("docker exec ${DOCKER_ID} bash -c 'cd ${deploy_build_dir} ; ./gradlew assembleRelease'")
}
stage("Deploy") {
sh("docker exec ${DOCKER_ID} bash -c 'cd ${deploy_build_dir} ; ./gradlew ${deploy_project}:uploadArchives'")
}
}
}
81 changes: 81 additions & 0 deletions Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Start with JDK8
FROM openjdk:8

ENV PGS_APP=android-test \
APP_MODULE=main:app

# Init dependencies for the setup process
RUN dpkg --add-architecture i386 \
&& apt-get update \
&& apt-get install -y \
build-essential \
expect \
software-properties-common \
unzip \
wget \
python-requests \
patch \
zlib1g-dev \
liblzma-dev \
pkg-config \
# Install 32-bit compatibility for 64-bit environments
libc6:i386 \
libncurses5:i386 \
libstdc++6:i386 \
zlib1g:i386 \
ruby-full \
ruby-dev \
# Cleanup
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

# Install bundler
RUN gem install bundler

# Set desired Android Linux SDK version
# ENV ANDROID_SDK_VERSION 25.2.3
# ENV ANDROID_SDK_ZIP tools_r${ANDROID_SDK_VERSION}-linux.zip
ENV ANDROID_SDK_ZIP sdk-tools-darwin-3859397.zip
ENV ANDROID_SDK_ZIP_URL https://dl.google.com/android/repository/${ANDROID_SDK_ZIP}
ENV ANDROID_HOME /opt/android-sdk-linux

ENV PATH ${PATH}:${ANDROID_HOME}/tools

# Install Android SDK
RUN mkdir -p ${ANDROID_HOME}

RUN cd ${ANDROID_HOME} \
&& wget --quiet ${ANDROID_SDK_ZIP_URL} \
&& unzip -q ${ANDROID_HOME}/${ANDROID_SDK_ZIP} -d ${ANDROID_HOME} \
&& rm ${ANDROID_HOME}/${ANDROID_SDK_ZIP}

RUN mkdir -p ${HOME}/.android
RUN touch ${HOME}/.android/repositories.cfg

RUN yes | ${ANDROID_HOME}/tools/bin/sdkmanager --licenses

RUN yes | ${ANDROID_HOME}/tools/bin/sdkmanager "build-tools;28.0.3"
RUN yes | ${ANDROID_HOME}/tools/bin/sdkmanager "platform-tools"
RUN yes | ${ANDROID_HOME}/tools/bin/sdkmanager "platforms;android-28"
RUN yes | ${ANDROID_HOME}/tools/bin/sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2"
RUN yes | ${ANDROID_HOME}/tools/bin/sdkmanager "extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2"

# Make SDK dir writable
RUN chmod -R a+w ${ANDROID_HOME}

# Add a "Home" directory for the user
ENV GRADLE_USER_HOME /gradle_home

RUN mkdir -p ${GRADLE_USER_HOME}

# ENV DUMMY_LOCAL_PROPERTIES local.properties.dummy
ENV DOCKER_GRADLE_HOME container-test-home
# create dummy local.properties to keep host environment's configs from overriding the Dockerfile ENV for android sdk bits
# RUN touch ${DUMMY_LOCAL_PROPERTIES}

# create a directory to mount as the container's GRADLE_USER_HOME to share the gradle cache from run to run
RUN mkdir -p ${DOCKER_GRADLE_HOME}

# Copy source files & install gradle
RUN mkdir build
COPY . ./build
40 changes: 40 additions & 0 deletions sqlite-android/android-release-aar.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// ./gradlew clean build generateRelease
apply plugin: 'maven'

def groupId = project.PUBLISH_GROUP_ID
def artifactId = project.PUBLISH_ARTIFACT_ID
def version = project.PUBLISH_VERSION

task androidJavadocs(type: Javadoc) {
failOnError = false
source = android.sourceSets.main.java.srcDirs
ext.androidJar = "${android.sdkDirectory}/platforms/${android.compileSdkVersion}/android.jar"
classpath += files(ext.androidJar)
}

task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
classifier = 'javadoc'
from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
classifier = 'sources'
from android.sourceSets.main.java.srcDirs
}

uploadArchives {
repositories.mavenDeployer {
pom.groupId = groupId
pom.artifactId = artifactId
pom.version = version
// Add other pom properties here if you want (developer details / licenses)
repository(url: "https://plangrid.jfrog.io/plangrid/libs-release-local") {
authentication(userName: System.getenv("ARTIFACTORY_USER"), password: System.getenv("ARTIFACTORY_PASSWORD"))
}
}
}

artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}
84 changes: 8 additions & 76 deletions sqlite-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ group = 'io.requery'
version = '3.30.1'
description = 'Android SQLite compatibility library'

ext {
PUBLISH_ARTIFACT_ID = name + "-plangrid"
PUBLISH_GROUP_ID = group
PUBLISH_VERSION = version
}

android {
compileSdkVersion 28

Expand Down Expand Up @@ -56,84 +62,8 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.0'
}

publish.dependsOn "assembleRelease"
bintrayUpload.dependsOn "assembleRelease"

ext {
sqliteDistributionUrl = 'https://sqlite.org/2019/sqlite-amalgamation-3300100.zip'
pomXml = {
resolveStrategy = DELEGATE_FIRST
name project.name
description project.description
url 'https://github.com/requery/sqlite-android'
scm {
url 'https://github.com/requery/sqlite-android.git'
connection 'scm:git:git://github.com/requery/sqlite-android.git'
developerConnection 'scm:git:[email protected]/requery/sqlite-android.git'
}
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/license/LICENSE-2.0.txt'
distribution 'repo'
}
}
developers {
developer {
id 'npurushe'
name 'Nikhil Purushe'
}
}
}
}

android.libraryVariants
publishing {
publications {
maven(MavenPublication) {
groupId project.group
artifactId project.name
version project.version
artifact "build/outputs/aar/${project.name}-release.aar"
artifact sourcesJar
artifact javadocJar
pom.withXml {
asNode().children().last() + project.pomXml
def dependencies = asNode().appendNode('dependencies')
configurations.compile.allDependencies.each {
def dependency = dependencies.appendNode('dependency')
dependency.appendNode('groupId', it.group)
dependency.appendNode('artifactId', it.name)
dependency.appendNode('version', it.version)
dependency.appendNode('scope', 'compile')
}
}
}
}
}

Properties properties = new Properties()
File localProperties = project.rootProject.file('local.properties')
if (localProperties.exists()) {
properties.load(localProperties.newDataInputStream())
}

bintray {
user = properties.getProperty('bintray.user')
key = properties.getProperty('bintray.apikey')
publications = ['maven']
pkg {
repo = 'requery'
name = 'sqlite-android'
userOrg = 'requery'
licenses = ['Apache-2.0']
vcsUrl = 'https://github.com/requery/sqlite-android.git'
version {
name = project.version
desc = project.description
released = new Date()
}
}
}

task sourcesJar(type: Jar) {
Expand Down Expand Up @@ -167,3 +97,5 @@ task installSqlite(dependsOn: downloadSqlite, type: Copy) {
}

preBuild.dependsOn installSqlite

apply from: 'android-release-aar.gradle'
1 change: 1 addition & 0 deletions sqlite-android/src/main/jni/sqlite/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ sqlite_flags := \
-DSQLITE_DEFAULT_MEMSTATUS=0 \
-DSQLITE_MAX_EXPR_DEPTH=0 \
-DSQLITE_USE_ALLOCA \
-DSQLITE_MAX_VARIABLE_NUMBER=32768 \
-DSQLITE_ENABLE_BATCH_ATOMIC_WRITE \
-O3

Expand Down