diff --git a/modules/ROOT/examples/java/src/com/couchbase/code_snippets/Examples.java b/modules/ROOT/examples/java/src/com/couchbase/code_snippets/Examples.java index f95073de7..7ffdc901e 100644 --- a/modules/ROOT/examples/java/src/com/couchbase/code_snippets/Examples.java +++ b/modules/ROOT/examples/java/src/com/couchbase/code_snippets/Examples.java @@ -137,11 +137,23 @@ public static void main (String [] args) throws CouchbaseLiteException, Interrup // end::getting-started[] // tag::getting-startedGradle[] + plugins { id 'java' id 'application' } +// Comment out the below line if no source code is Kotlin +kotlinOptions { jvmTarget = '1.8' } + +// Set minimum JVM level to ensure availability of, for example, lambda expressions +compileOptions +{ + targetCompatibility 1.8 + sourceCompatibility 1.8 +}  + +// Declare repositories repositories { // Add your Maven/Ivy/file repository here. jcenter() @@ -170,20 +182,31 @@ implementation fileTree(include: ['*.jar'], dir: libs> id 'java' id 'application' } -allprojects { - repositories { - google() - jcenter() - maven { - url "https://mobile.maven.couchbase.com/maven2/dev/" - } + +// Comment out the below line if no source code is Kotlin +kotlinOptions { jvmTarget = '1.8' } + +// Set minimum JVM level to ensure availability of, for example, lambda expressions +compileOptions +{ + targetCompatibility 1.8 + sourceCompatibility 1.8 +}  + +repositories { + maven { + url "https://mobile.maven.couchbase.com/maven2/dev/" } + google() + jcenter() } + + dependencies { -// Use for Enterprise version +// Comment out below line if using Enterprise version + implementation "com.couchbase.lite:couchbase-lite-java:2.7.0" +// Comment out below line if using Community version implementation "com.couchbase.lite:couchbase-lite-java-ee:2.7.0" -// Use for community versions -// implementation "com.couchbase.lite:couchbase-lite-java:2.7.0" } application { diff --git a/modules/ROOT/pages/_partials/gsBuildGradleAndroid.adoc b/modules/ROOT/pages/_partials/gsBuildGradleAndroid.adoc new file mode 100644 index 000000000..60ec71265 --- /dev/null +++ b/modules/ROOT/pages/_partials/gsBuildGradleAndroid.adoc @@ -0,0 +1,54 @@ +// tag::allContent[] + +// Define the main class for the application. +application {mainClassName = 'gettingstarted.GettingStarted'} + +plugins { + id 'java' + id 'application' +// ... other section content as required by user +} + + +// tag::compileOptions[] +android { + // Required only if your project has some Kotlin source code + kotlinOptions { jvmTarget = '1.8' } + + // Set minimum JVM level to ensure availability of, for example, lambda expressions + compileOptions { + targetCompatibility 1.8 + sourceCompatibility 1.8 + }  + +// ... other section content as required by user +} +// end::compileOptions[] + +// tag::dependencies[] +dependencies { + implementation "com.couchbase.lite:couchbase-lite-android-ee:${version}" + +// ... other section content as required by user +} +// end::dependencies[] + +// tag::repositories[] +repositories { + maven { url 'https://mobile.maven.couchbase.com/maven2/dev/' } + google() + jcenter() + +// ... other section content as required by user +} +// end::repositories[] + +// end::allContent[] + +// tag::dependenciesCE[] +dependencies { + implementation "com.couchbase.lite:couchbase-lite-android:${version}" + +// ... other section content as required by user +} +// end::dependenciesCE[] diff --git a/modules/ROOT/pages/_partials/gsBuildGradleJava.adoc b/modules/ROOT/pages/_partials/gsBuildGradleJava.adoc new file mode 100644 index 000000000..69d3b0417 --- /dev/null +++ b/modules/ROOT/pages/_partials/gsBuildGradleJava.adoc @@ -0,0 +1,50 @@ + +:packageNm: couchbase-lite-java +// tag::allContent[] + +// Define the main class for the application. +application {mainClassName = 'gettingstarted.GettingStarted'} + +plugins { + id 'java' + id 'application' +} + +// tag::compileOptions[] +// Required only if your project has some Kotlin source code +kotlinOptions { jvmTarget = '1.8' } + +// Set minimum JVM level to ensure availability of, for example, lambda expressions +compileOptions { + targetCompatibility 1.8 + sourceCompatibility 1.8 + +// ... other section content as required by user +}  +// end::compileOptions[] + +// tag::dependencies[] +dependencies { + implementation "com.couchbase.lite:couchbase-lite-java-ee:${version}" + +// ... other section content as required by user + } +// end::dependencies[] + +// tag::repositories[] +repositories { + maven {url 'https://mobile.maven.couchbase.com/maven2/dev/'} + +// ... other section content as required by user + } +// end::repositories[] + +// end::allContent[] + +// tag::dependenciesCE[] +dependencies { + implementation "com.couchbase.lite:couchbase-lite-java:${version}" + +// ... other section content as required by user +} +// end::dependenciesCE[] diff --git a/modules/ROOT/pages/java-android.adoc b/modules/ROOT/pages/java-android.adoc index 53a938970..2e8b192a7 100644 --- a/modules/ROOT/pages/java-android.adoc +++ b/modules/ROOT/pages/java-android.adoc @@ -6,6 +6,7 @@ :ziputils: {examplesdir}/java-android/app/src/main/java/com/couchbase/code_snippets/ZipUtils.java :source-language: java :version: 2.7.0 +:packageNm: couchbase-lite-android :blank-field: ____ :url-issues-java: https://github.com/couchbase/couchbase-lite-android/issues :url-api-references: http://docs.couchbase.com/mobile/{version}/couchbase-lite-android @@ -16,47 +17,57 @@ include::_attributesLocal.adoc[] == Getting Started +Create or open an existing Android Studio project and install Couchbase Lite using the following method. -=== Android Studio +Make the following additions to the module-level `build.gradle` file (typically in the *app* folder). -Create or open an existing Android Studio project and install Couchbase Lite using the following method. -==== Couchbase Lite Community Edition +[{tabs}] +==== +Community:: ++ +-- +. Include the following in the `android {}` section: ++ +[source,groovy] +---- +include::partial$gsBuildGradleAndroid.adoc[tag=compileOptions] +---- +. Include the following in the `dependencies{}` section: ++ +[source,groovy] +---- +include::partial$gsBuildGradleAndroid.adoc[tag=dependenciesCE] +---- -* Add the following in the `dependencies` section of the application's *build.gradle* (the one in the *app* folder). +-- +Enterprise:: + -[source,groovy,subs=attributes+] +-- +. Include the following in the `android {}` section: ++ +[source,groovy] ---- -dependencies { - implementation 'com.couchbase.lite:couchbase-lite-android:{version}' -} +include::partial$gsBuildGradleAndroid.adoc[tag=compileOptions] ---- -==== Couchbase Lite Enterprise Edition -* In the top-level *build.gradle* file, add the following Couchbase Maven repository in the `allprojects` section. +. Include the following in the `dependencies{}` section: + [source,groovy] ---- -allprojects { - repositories { - google() - jcenter() - maven { - url "https://mobile.maven.couchbase.com/maven2/dev/" - } - } -} +include::partial$gsBuildGradleAndroid.adoc[tag=dependencies] ---- - -* Next, add the following in the `dependencies` section of the application's *build.gradle* (the one in the *app* folder). + -[source,groovy,subs=attributes+] +. Include the following in the `repositories {}` section: ++ +[source,groovy] ---- -dependencies { - implementation 'com.couchbase.lite:couchbase-lite-android-ee:{version}' -} +include::partial$gsBuildGradleAndroid.adoc[tag=repositories] ---- +-- +==== + === Starter code diff --git a/modules/ROOT/pages/java-platform.adoc b/modules/ROOT/pages/java-platform.adoc index 2d4d81a6c..3b13cfe54 100644 --- a/modules/ROOT/pages/java-platform.adoc +++ b/modules/ROOT/pages/java-platform.adoc @@ -3,8 +3,9 @@ include::partial$mobAttrCBL.adoc[] :JP: Java :Android: Java (android) :cblJP: {product} {JP} -:packageNmCE: couchbase-lite-java-{version-full} -:packageNmEE: couchbase-lite-java-ee-{version-full} +:packageNm: couchbase-lite-java +:packageNmCE: {packageNm}-{version-full} +:packageNmEE: {packageNm}-ee-{version-full} :url-api-references: http://docs.couchbase.com/mobile/{version-full}/couchbase-lite-java :hdIndent: :snippet: {snippet-java-jvm} @@ -61,10 +62,8 @@ It assumes a familiarity with these products, however you are free to use your o The contents of your `build.gradle` file will depend on the type of project you are building, whether you are using Community or Enterprise edition and whether you prefer to use Maven-distributed binaries or a zip download. - TIP: If you wish to use a downloaded zip instead of Maven then see - <> - NOTE: If you are deploying to Linux, you will need the {cbl} `support` library, which is available _only_ on the zip download distributable -- see <> anchor:bmkUsingMavenRepos[Using Maven repositories] @@ -81,34 +80,42 @@ Console App Development:: . Create a project folder . Initialize it for a Gradle Java application -. Create your `build.gradle` file, including the following repositories and dependencies: +. Include the following in the `build.gradle` file: -* For Community edition +Community edition:: + -[source,groovy,subs=attributes+] +Compile options ++ +[source,groovy] ---- -dependencies { - implementation 'com.couchbase.lite:couchbase-lite-java:2.7.0' -} +include::partial$gsBuildGradleJava.adoc[tag=compileOptions] ---- - -* For Enterprise Edition +Dependencies + [source,groovy] +---- +include::partial$gsBuildGradleJava.adoc[tag=dependenciesCE] +---- +Enterprise Edition:: ++ +Compile options ++ +[source,groovy] ---- -allprojects { - repositories { - google() - jcenter() - maven { - url "https://mobile.maven.couchbase.com/maven2/dev/" - } - } -} -dependencies { - implementation 'com.couchbase.lite:couchbase-lite-java-ee:2.7.0' -} +include::partial$gsBuildGradleJava.adoc[tag=compileOptions] +---- +Dependencies ++ +[source,groovy] +---- +include::partial$gsBuildGradleJava.adoc[tag=dependencies] +---- +Repositories ++ +[source,groovy] +---- +include::partial$gsBuildGradleJava.adoc[tag=repositories] ---- . Open the project folder in {gpIDE} and import the {gpBuildTool} settings. @@ -127,9 +134,9 @@ That's it. You're all set to start building your own {cblJP} applications -- see .Sample build.gradle content -[source,groovy,subs=attributes+] +[source,groovy] ---- -include::{snippet}[tags=gsGradleMavenExample,indent=0] +include::partial$gsBuildGradleJava.adoc[tag=allContent] ---- -- @@ -182,9 +189,7 @@ gradle init + [source,groovy,subs=attributes+] ---- -dependencies { - implementation 'com.couchbase.lite:couchbase-lite-java:2.7.0' -} +include::partial$gsBuildGradleJava.adoc[tag=dependenciesCE] ---- * For Enterprise Edition @@ -192,18 +197,8 @@ dependencies { [source,groovy] ---- -allprojects { - repositories { - google() - jcenter() - maven { - url "https://mobile.maven.couchbase.com/maven2/dev/" - } - } -} -dependencies { - implementation 'com.couchbase.lite:couchbase-lite-java-ee:2.7.0' -} +include::partial$gsBuildGradleJava.adoc[tag=repositories] +include::partial$gsBuildGradleJava.adoc[tag=dependencies] ---- . Open the project folder in {gpIDE} and import the {gpBuildTool} settings.