This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Utility installation script to work with Android Couchbase
Change-Id: I13ee3f4b6f9e232601369af51de7a513e0acdfe8 Reviewed-on: http://review.couchbase.org/9104 Reviewed-by: Marty Schoch <marty.schoch@gmail.com> Reviewed-by: Dale Harvey <daleharvey@arandomurl.com> Tested-by: Dale Harvey <daleharvey@arandomurl.com>
- Loading branch information
Showing
12 changed files
with
427 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType"> | ||
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/> | ||
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/> | ||
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/> | ||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/> | ||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="@PROJECT.NAME@"/> | ||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/> | ||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/@PROJECT.NAME@/couchbase-build.xml}"/> | ||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="full,incremental,"/> | ||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="-d -v"/> | ||
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/> | ||
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/@PROJECT.NAME@}"/> | ||
</launchConfiguration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project name="add-couchbase-to-project" default="install"> | ||
|
||
<property file="local.properties"/> | ||
|
||
<taskdef name="showform" classname="com.couchbase.ShowForm" classpath="couchbase-form.jar"/> | ||
|
||
<condition property="is.windows"> | ||
<os family="windows"/> | ||
</condition> | ||
|
||
<condition property="is.unix"> | ||
<os family="unix"/> | ||
</condition> | ||
|
||
<target name="install" depends="_get-inputs, _validate-project-path, _get-project-name, _real-install"/> | ||
|
||
<target name="install-cmdline" depends="_get-android-sdk, _get-project-path, _validate-project-path, _get-project-name, _real-install"/> | ||
|
||
<target name="_check-android-sdk"> | ||
<condition property="android-sdk-set"> | ||
<isset property="sdk.dir"/> | ||
</condition> | ||
</target> | ||
|
||
<target name="_get-android-sdk" depends="_check-android-sdk" unless="sdk.dir"> | ||
<input message="Android SDK Path" addproperty="sdk.dir"/> | ||
</target> | ||
|
||
<target name="_get-project-path"> | ||
<input message="Project Path" addproperty="project.path"/> | ||
</target> | ||
|
||
<target name="_validate-project-path"> | ||
|
||
<!-- debug only --> | ||
<exec executable="ls" outputproperty="ls.project.output"> | ||
<arg value="-al"/> | ||
<arg value="${project.path}"/> | ||
</exec> | ||
<echo>Project directory contains: | ||
${ls.project.output} | ||
</echo> | ||
|
||
<path id="debug.path"> | ||
<fileset dir="${project.path}"> | ||
<include name="**/*"/> | ||
</fileset> | ||
</path> | ||
<property name="debug.path.property" refid="debug.path"/> | ||
<echo>Project fileset contains: | ||
${debug.path.property} | ||
</echo> | ||
|
||
<condition property="project.path.exists.as.directory"> | ||
<available file="${project.path}" type="dir"/> | ||
</condition> | ||
<fail message="The project path ${project.path} does not exist." unless="project.path.exists.as.directory"/> | ||
<condition property="project.path.looks.like.project"> | ||
<available file="${project.path}/.project" type="file"/> | ||
</condition> | ||
<fail message="The project path ${project.path} does not contain contain a .project file." unless="project.path.looks.like.project"/> | ||
</target> | ||
|
||
<!-- read the .project file to deterimine the project name --> | ||
<target name="_get-project-name"> | ||
<xmlproperty file="${project.path}/.project"/> | ||
</target> | ||
|
||
<target name="_guess-android-sdk-dir"> | ||
<exec executable="bash" outputproperty="sdk.dir.guess.full" failifexecutionfails="false" failonerror="false"> | ||
<arg value="-l"/> | ||
<arg value="-c"/> | ||
<arg value="type -P android"/> | ||
</exec> | ||
<property name="sdk.dir.guess" location="${sdk.dir.guess.full}/../.."/> | ||
<echo>Guessing Android Dir: ${sdk.dir.guess}</echo> | ||
</target> | ||
|
||
<target name="_get-inputs"> | ||
|
||
<showform/> | ||
<echo>Android SDK is ${sdk.dir}</echo> | ||
<echo>Project Path is ${project.path}</echo> | ||
|
||
</target> | ||
|
||
<target name="do-windows" if="is.windows"> | ||
<echo>Copying ${user.dir}/couchbase-build.xml to ${project.path}/couchbase-build.xml</echo> | ||
<copy file="couchbase-build.xml" tofile="${project.path}/couchbase-build.xml" overwrite="true"></copy> | ||
</target> | ||
|
||
<target name="do-unix" if="is.unix"> | ||
<echo>Symlinking ${project.path}/couchbase-build.xml to ${user.dir}/couchbase-build.xml</echo> | ||
<symlink link="${project.path}/couchbase-build.xml" resource="${user.dir}/couchbase-build.xml" overwrite="true" /> | ||
</target> | ||
|
||
<target name="_real-install" depends="_get-android-sdk, _get-project-path, _get-project-name, do-windows, do-unix"> | ||
|
||
<echo>Android SDK: ${sdk.dir}</echo> | ||
<echo>Project Path: ${project.path}</echo> | ||
<echo>Project Name: ${projectDescription.name}</echo> | ||
|
||
<property name="android.couchbase.dir" location=".."/> | ||
|
||
<!-- copy build.properties replacing values in template --> | ||
<copy file="build.properties.template" tofile="${project.path}/build.properties"> | ||
<filterset> | ||
<filter token="SDK.DIR" value="${sdk.dir}"/> | ||
<filter token="ANDROID.COUCHBASE.DIR" value="${android.couchbase.dir}"/> | ||
</filterset> | ||
</copy> | ||
|
||
<!-- make external tool builders dir --> | ||
<mkdir dir="${project.path}/.externalToolBuilders/"/> | ||
|
||
<!-- copy builder launch configuration replacing values in template --> | ||
<copy file="CouchbaseBuilder.launch.template" tofile="${project.path}/.externalToolBuilders/CouchbaseBuilder.launch"> | ||
<filterset> | ||
<filter token="PROJECT.NAME" value="${projectDescription.name}"/> | ||
</filterset> | ||
</copy> | ||
|
||
<!-- backup the .project file --> | ||
<copy file="${project.path}/.project" tofile="${project.path}/.project.orig"/> | ||
|
||
<!-- update the .project file to reference Couchbase builder --> | ||
<xslt style="project.xsl" in="${project.path}/.project.orig" out="${project.path}/.project"></xslt> | ||
|
||
<!-- invoke ant on couchbase-build.xml in the new project --> | ||
<ant antfile="${project.path}/couchbase-build.xml" target="all" dir="${project.path}"/> | ||
|
||
</target> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
sdk.dir=@SDK.DIR@ | ||
android.couchbase.dir=@ANDROID.COUCHBASE.DIR@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<xsl:stylesheet version="1.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | ||
|
||
<xsl:template match="@*|node()"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@*|node()"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<xsl:template match="classpath"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@*|node()"/> | ||
<classpathentry kind="lib" path="/Android-Couchbase/lib/commons-compress-1.0.jar"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project name="couchbase-build" default="all"> | ||
|
||
<property file="build.properties" /> | ||
|
||
<target name="help"> | ||
<echo> | ||
To use this script, please set the property android.couchbase.dir in your build.properties file to | ||
point to the location you installed Android-Couchbase. | ||
|
||
The following targets are available: | ||
|
||
add-couchbase-android-library-reference - Check/Add requried Android-Couchbase library reference | ||
update-couchbase-android-assets - Check/Update required Android-Couchbase assets | ||
check-manifest-permissions - Check/Suggest required permissions in AndroidManifest.xml | ||
suggest-manifest-service - Check/Suggest required service definition in AndroidManifest.xml | ||
|
||
all - Run all checks | ||
</echo> | ||
|
||
</target> | ||
|
||
<target name="all" depends="add-couchbase-android-library-reference,update-classpath,update-couchbase-android-assets,check-manifest-permissions,suggest-manifest-service"> | ||
</target> | ||
|
||
<!-- Library Reference --> | ||
|
||
<target name="check-couchbase-android-library-reference" depends="_init"> | ||
<condition property="contains.android.library.reference"> | ||
<resourcecontains resource="${basedir}/default.properties" substring="Android-Couchbase"/> | ||
</condition> | ||
</target> | ||
|
||
<target name="add-couchbase-android-library-reference" depends="check-couchbase-android-library-reference" unless="contains.android.library.reference"> | ||
<!-- Convert the path to a relative path --> | ||
<property name="rel.android.couchbase.dir" location="${android.couchbase.dir}" relative="true"/> | ||
<exec executable="${sdk.dir}/tools/android"> | ||
<arg value="update"/> | ||
<arg value="project"/> | ||
<arg value="--path"/> | ||
<arg value="${basedir}"/> | ||
<arg value="--library"/> | ||
<arg value="${rel.android.couchbase.dir}"/> | ||
</exec> | ||
</target> | ||
|
||
<!-- Assets --> | ||
|
||
<target name="check-couchbase-android-assets" depends="_init"> | ||
<uptodate property="android.couchbase.assets.uptodate"> | ||
<srcfiles dir= "${android.couchbase.dir}/assets" includes="**/*"/> | ||
<mapper type="glob" from="couchbase-*.tgz.jpg" | ||
to="${basedir}/assets/couchbase-*.tgz.jpg"/> | ||
</uptodate> | ||
</target> | ||
|
||
<target name="update-couchbase-android-assets" depends="check-couchbase-android-assets" unless="android.couchbase.assets.uptodate"> | ||
<copy todir="${basedir}/assets/"> | ||
<fileset dir="${android.couchbase.dir}/assets" includes="**/*.tgz.jpg"/> | ||
<globmapper from="*" to="*"/> | ||
</copy> | ||
<echo>Your Android-Couchbase assets have been updated, you may remove the old assets.</echo> | ||
</target> | ||
|
||
<!-- Permissions --> | ||
|
||
<target name="check-manifest-permissions" depends="suggest-manifest-permission.ACCESS_NETWORK_STATE,suggest-manifest-permission.INTERNET,suggest-manifest-permission.WRITE_EXTERNAL_STORAGE"> | ||
<delete file="AndroidManifest.xml.orig.p1"/> | ||
<delete file="AndroidManifest.xml.orig.p2"/> | ||
<delete file="AndroidManifest.xml.orig.p3"/> | ||
<delete file="AndroidManifest.xml.orig.cs"/> | ||
</target> | ||
|
||
<target name="suggest-manifest-permission.ACCESS_NETWORK_STATE" | ||
depends="check-manifest-permission.ACCESS_NETWORK_STATE" | ||
unless="permission.ACCESS_NETWORK_STATE"> | ||
<!-- backup existing AndroidManifest.xml --> | ||
<copy file="AndroidManifest.xml" tofile="AndroidManifest.xml.orig.p1"/> | ||
<xslt style="${android.couchbase.dir}/script/permission-ACCESS_NETWORK_STATE.xsl" in="AndroidManifest.xml.orig.p1" out="AndroidManifest.xml" force="true"></xslt> | ||
</target> | ||
|
||
<target name="check-manifest-permission.ACCESS_NETWORK_STATE" depends="_init"> | ||
<condition property="permission.ACCESS_NETWORK_STATE"> | ||
<resourcecontains resource="${basedir}/AndroidManifest.xml" substring="android.permission.ACCESS_NETWORK_STATE"/> | ||
</condition> | ||
</target> | ||
|
||
<target name="suggest-manifest-permission.INTERNET" | ||
depends="check-manifest-permission.INTERNET" | ||
unless="permission.INTERNET"> | ||
<!-- backup existing AndroidManifest.xml --> | ||
<copy file="AndroidManifest.xml" tofile="AndroidManifest.xml.orig.p2"/> | ||
<xslt style="${android.couchbase.dir}/script/permission-INTERNET.xsl" in="AndroidManifest.xml.orig.p2" out="AndroidManifest.xml" force="true"></xslt> | ||
</target> | ||
|
||
<target name="check-manifest-permission.INTERNET" depends="_init"> | ||
<condition property="permission.INTERNET"> | ||
<resourcecontains resource="${basedir}/AndroidManifest.xml" substring="android.permission.INTERNET"/> | ||
</condition> | ||
</target> | ||
|
||
<target name="suggest-manifest-permission.WRITE_EXTERNAL_STORAGE" | ||
depends="check-manifest-permission.WRITE_EXTERNAL_STORAGE" | ||
unless="permission.WRITE_EXTERNAL_STORAGE"> | ||
<!-- backup existing AndroidManifest.xml --> | ||
<copy file="AndroidManifest.xml" tofile="AndroidManifest.xml.orig.p3"/> | ||
<xslt style="${android.couchbase.dir}/script/permission-WRITE_EXTERNAL_STORAGE.xsl" in="AndroidManifest.xml.orig.p3" out="AndroidManifest.xml" force="true"></xslt> | ||
</target> | ||
|
||
<target name="check-manifest-permission.WRITE_EXTERNAL_STORAGE"> | ||
<condition property="permission.WRITE_EXTERNAL_STORAGE"> | ||
<resourcecontains resource="${basedir}/AndroidManifest.xml" substring="android.permission.WRITE_EXTERNAL_STORAGE"/> | ||
</condition> | ||
</target> | ||
|
||
<!-- Service --> | ||
<target name="suggest-manifest-service" | ||
depends="check-manifest-service" | ||
unless="service.couch.exists"> | ||
<!-- backup existing AndroidManifest.xml --> | ||
<copy file="AndroidManifest.xml" tofile="AndroidManifest.xml.orig.cs"/> | ||
<xslt style="${android.couchbase.dir}/script/couchbase-service.xsl" in="AndroidManifest.xml.orig.cs" out="AndroidManifest.xml" force="true"></xslt> | ||
</target> | ||
|
||
<target name="check-manifest-service"> | ||
<condition property="service.couch.exists"> | ||
<resourcecontains resource="${basedir}/AndroidManifest.xml" substring="com.couchbase.libcouch.CouchService"/> | ||
</condition> | ||
</target> | ||
|
||
<target name="check-classpath"> | ||
<condition property="commons.compress.exists"> | ||
<resourcecontains resource="${basedir}/.classpath" substring="/Android-Couchbase/lib/commons-compress-1.0.jar"/> | ||
</condition> | ||
</target> | ||
|
||
<target name="update-classpath" depends="check-classpath" unless="commons.compress.exists"> | ||
<!-- backup existing .classpath --> | ||
<copy file=".classpath" tofile=".classpath.orig"/> | ||
<xslt style="${android.couchbase.dir}/script/classpath.xsl" in=".classpath.orig" out=".classpath"></xslt> | ||
</target> | ||
|
||
<target name="_init"> | ||
<!-- don't continue if it appears android.couchbase.dir is set incorrectly --> | ||
<available file="${android.couchbase.dir}/src/com/couchbase/libcouch/CouchbaseMobile.java" | ||
property="android.couchbase.dir.valid"/> | ||
<fail message="Property android.couchbase.dir does not appear to be set correctly." unless="android.couchbase.dir.valid"/> | ||
</target> | ||
|
||
</project> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<xsl:stylesheet version="1.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<xsl:template match="@*|node()"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@*|node()"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<xsl:template match="application"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@*|node()"/> | ||
<service android:name="com.couchbase.libcouch.CouchService" android:enabled="true" android:exported="false"></service> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#optionally set these properties here so that you are not prompted each time | ||
|
||
#path to Android SDK | ||
#sdk.dir= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<xsl:stylesheet version="1.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<xsl:template match="@*|node()"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@*|node()"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<xsl:template match="manifest"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@*|node()"/> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<xsl:stylesheet version="1.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<xsl:template match="@*|node()"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@*|node()"/> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
<xsl:template match="manifest"> | ||
<xsl:copy> | ||
<xsl:apply-templates select="@*|node()"/> | ||
<uses-permission android:name="android.permission.INTERNET"></uses-permission> | ||
</xsl:copy> | ||
</xsl:template> | ||
|
||
</xsl:stylesheet> |
Oops, something went wrong.