Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-writing accessors transformer using the new AGP API #7694

Merged
merged 31 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e2419af
re-writing accessors transformer using the new AGP API
nhachicha Jun 30, 2022
fbb9f08
cleanup
nhachicha Jun 30, 2022
8a3c558
Using Java 11
nhachicha Jul 10, 2022
a9a2575
Silencing Javadoc
nhachicha Jul 11, 2022
15a02d5
Project already evaluated
nhachicha Jul 11, 2022
207e5bc
WIP
nhachicha Jul 27, 2022
bf97b43
Fix sdk tests and all examples
rorbech Aug 10, 2022
13a9de5
Fix kotlin-extension tests
rorbech Aug 12, 2022
e1aeed2
Fix example projects according to latest updates
rorbech Aug 12, 2022
8ad69c6
Merge branch 'master' into nh/new_transformer
rorbech Aug 15, 2022
134a9bd
Revert annotations JDK target update
rorbech Aug 16, 2022
df23338
Fix processor test encoding issues
rorbech Aug 16, 2022
33081ef
Ensure JNI headers are generated before native build
rorbech Aug 16, 2022
3d780c8
Fix automatic dependency setup
rorbech Aug 22, 2022
f8940ce
Update to Core 12.5.1 and tests for raw queries with keyword field na…
rorbech Aug 29, 2022
1af01b7
Strip object server symbols from base artifacts
rorbech Aug 30, 2022
58a791e
Clean up
rorbech Aug 30, 2022
d895320
Merge branch 'master' into nh/new_transformer
rorbech Aug 30, 2022
8f17c24
Update version
rorbech Aug 30, 2022
eae54a1
Add CHANGELOG entry
rorbech Aug 31, 2022
98c6bbe
Update config.yml
geragray Sep 6, 2022
77225f1
Update config.yml
geragray Sep 6, 2022
a4f034b
Update config.yml
geragray Sep 6, 2022
535bfb2
Merge pull request #7718 from realm/geragray-patch-1
Sep 7, 2022
143fe75
Bump core 1.6.0 (#7717)
clementetb Sep 7, 2022
d7f3fda
Merge branch 'releases'
clementetb Sep 7, 2022
64a7000
Remove export compliance clause
nielsenko Sep 8, 2022
ba633a7
Merge pull request #7721 from realm/kn/clean-license
Sep 8, 2022
b057cab
Refactor EmailPasswordAuth tests to be less flaky. (#7723)
Sep 13, 2022
0357c11
Updates according to review comments
rorbech Sep 14, 2022
f7cde57
Merge branch 'master' into nh/new_transformer
rorbech Sep 15, 2022
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
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ contact_links:
- name: General Questions and Inquiries
url: https://www.mongodb.com/community/forums/tags/c/realm-sdks/58/java
about: Please ask general design/architecture questions in the community forums.
- name: MongoDB Realm (Sync) Production Issues
- name: MongoDB Atlas Device Sync Production Issues
url: https://support.mongodb.com/
about: Please report urgent production issues to the support portal directly.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
## 10.12.0 (YYYY-MM-DD)
## 10.12.0-transformer-api (YYYY-MM-DD)

### Breaking Changes
* Only works with Android Gradle Plugin 7.4 or newer. (Issue [#7714](https://github.com/realm/realm-java/issues/7714))

### Enhancements
* [RealmApp] Introduced `SyncSession.RecoverOrDiscardUnsyncedChangesStrategy`, an alternative automatic client reset strategy that tries to automatically recover any unsynced data from the client, and discards any unsynced data if not possible. This is now the default client reset policy if not explicitly set in the `SyncConfiguration`.
* [RealmApp] Introduced `SyncSession.RecoverUnsyncedChangesStrategy`, an alternative automatic client reset strategy that tries to automatically recover any unsynced data from the client and will revert to manual client reset if not possible.

### Fixed
* None
* Now queries can point to fields with query language-reserved words like 'desc', 'sort', 'distinct', etc. Issue [#7705](https://github.com/realm/realm-java/issues/7705)

### Compatibility
* File format: Generates Realms with format v22. Unsynced Realms will be upgraded from Realm Java 2.0 and later. Synced Realms can only be read and upgraded if created with Realm Java v10.0.0-BETA.1.
* APIs are backwards compatible with all previous release of realm-java in the 10.6.y series.
* Realm Studio 11.0.0-alpha.0 or above is required to open Realms created by this version.

### Internal
* Update to Realm Core 12.6.0, commit: 5da7744b4056ad185c025bccf0924f17f73f7a91.


## 10.11.1 (2022-07-14)

Expand Down
7 changes: 4 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,9 @@ try {
[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'realm-kotlin-baas-aws-credentials', accessKeyVariable: 'BAAS_AWS_ACCESS_KEY_ID', secretKeyVariable: 'BAAS_AWS_SECRET_ACCESS_KEY']
]) {
def tempDir = runCommand('mktemp -d -t app_config.XXXXXXXXXX')
sh "tools/sync_test_server/app_config_generator.sh ${tempDir} tools/sync_test_server/app_template partition testapp1 testapp2"
sh "tools/sync_test_server/app_config_generator.sh ${tempDir} tools/sync_test_server/app_template flex testapp3"
sh "tools/sync_test_server/app_config_generator.sh ${tempDir} tools/sync_test_server/app_template partition auto testapp1"
sh "tools/sync_test_server/app_config_generator.sh ${tempDir} tools/sync_test_server/app_template partition email testapp2"
sh "tools/sync_test_server/app_config_generator.sh ${tempDir} tools/sync_test_server/app_template flex function testapp3"
sh "docker network create ${dockerNetworkId}"
mongoDbRealmContainer = mdbRealmImage.run("--network ${dockerNetworkId} -v$tempDir:/apps -e AWS_ACCESS_KEY_ID='$BAAS_AWS_ACCESS_KEY_ID' -e AWS_SECRET_ACCESS_KEY='$BAAS_AWS_SECRET_ACCESS_KEY'")
mongoDbRealmCommandServerContainer = commandServerEnv.run("--network container:${mongoDbRealmContainer.id} -v$tempDir:/apps")
Expand Down Expand Up @@ -162,7 +163,7 @@ try {
sh """yes '\n' | avdmanager create avd -n CIEmulator -k '${emulatorImage}' --force"""
sh "adb start-server" // https://stackoverflow.com/questions/56198290/problems-with-adb-exe
// Need to go to ANDROID_HOME due to https://askubuntu.com/questions/1005944/emulator-avd-does-not-launch-the-virtual-device
sh "cd \$ANDROID_HOME/tools && emulator -avd CIEmulator -no-boot-anim -no-window -wipe-data -noaudio -partition-size 4098 &"
sh "cd \$ANDROID_HOME/tools && emulator -avd CIEmulator -no-boot-anim -no-window -wipe-data -noaudio -partition-size 4098 -memory 2048 &"
try {
runBuild(buildFlags, instrumentationTestTarget)
} finally {
Expand Down
31 changes: 2 additions & 29 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
TABLE OF CONTENTS

1. Apache License version 2.0
2. Export Compliance

1. -------------------------------------------------------------------------------

Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
Expand Down Expand Up @@ -180,25 +173,5 @@ TABLE OF CONTENTS
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.

2. -------------------------------------------------------------------------------

EXPORT COMPLIANCE

You understand that the Software may contain cryptographic functions that may be
subject to export restrictions, and you represent and warrant that you are not
(i) located in a jurisdiction that is subject to United States economic
sanctions (“Prohibited Jurisdiction”), including Cuba, Iran, North Korea,
Sudan, Syria or the Crimea region, (ii) a person listed on any U.S. government
blacklist (to include the List of Specially Designated Nationals and Blocked
Persons or the Consolidated Sanctions List administered by the U.S. Department
of the Treasury’s Office of Foreign Assets Control, or the Denied Persons List
or Entity List administered by the U.S. Department of Commerce)
(“Sanctioned Person”), or (iii) controlled or 50% or more owned by a Sanctioned
Person.

You agree to comply with all export, re-export and import restrictions and
regulations of the U.S. Department of Commerce or other agency or authority of
the United States or other applicable countries. You also agree not to transfer,
or authorize the transfer of, directly or indirectly, of the Software to any
Prohibited Jurisdiction, or otherwise in violation of any such restrictions or
regulations.
END OF TERMS AND CONDITIONS

4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,6 @@ Realm Java is published under the Apache 2.0 license.
Realm Core is also published under the Apache 2.0 license and is available
[here](https://github.com/realm/realm-core).

**This product is not being made available to any person located in Cuba, Iran,
North Korea, Sudan, Syria or the Crimea region, or to any other person that is
not eligible to receive the product under U.S. law.**

## Feedback

**_If you use Realm and are happy with it, all we ask is that you, please consider sending out a tweet mentioning [@realm](http://twitter.com/realm) to share your thoughts!_**
Expand Down
8 changes: 4 additions & 4 deletions dependencies.list
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Realm Core release used by Realm Java
# https://github.com/realm/realm-core/releases
REALM_CORE=12.3.0
REALM_CORE=12.6.0

# Version of MongoDB Realm used by integration tests
# See https://github.com/realm/ci/packages/147854 for available versions
Expand All @@ -15,10 +15,10 @@ REALM_BAAS_GIT_HASH=ba172f8dd37c3102499ab7d728e7c0dcb9e52ae8
REALM_BAAS_UI_GIT_HASH=1fc10a6e04f87247790662d825500c9e21dbfbc7

# Common Android settings across projects
GRADLE_BUILD_TOOLS=7.1.0
GRADLE_BUILD_TOOLS=7.4.0-alpha08
ANDROID_BUILD_TOOLS=30.0.3
KOTLIN=1.5.31
KOTLIN_COROUTINES=1.5.2
KOTLIN=1.6.21
KOTLIN_COROUTINES=1.6.0

# Common classpath dependencies
gradle=7.3.3
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static class ViewHolder extends RecyclerView.ViewHolder {
return;
}
AppCompatActivity activity = ContextUtils.findActivity(view.getContext());
PersonFragment personFragment = PersonFragment.create(person.getName());
PersonFragment personFragment = PersonFragment.create(person.name);
activity.getSupportFragmentManager()
.beginTransaction()
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public class Person extends RealmObject {
@Index
private String name;
public String name;

private int age;

Expand Down
13 changes: 7 additions & 6 deletions examples/coroutinesExample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ apply plugin: 'kotlin-kapt'
apply plugin: 'realm-android'

android {
compileSdkVersion rootProject.sdkVersion
// androidx.lifecycle dependencies requires Android APIs 31 or later
compileSdkVersion 31
buildToolsVersion rootProject.buildTools

defaultConfig {
Expand Down Expand Up @@ -57,18 +58,18 @@ dependencies {

implementation "androidx.fragment:fragment-ktx:1.2.5"

implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-common-java8:2.2.0"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.4.0"
implementation "androidx.lifecycle:lifecycle-common-java8:2.4.0"

implementation "androidx.legacy:legacy-support-v4:1.0.0"

implementation "androidx.multidex:multidex:2.0.1"

implementation "androidx.recyclerview:recyclerview:1.1.0"

implementation "com.dropbox.mobile.store:store4:4.0.0"
implementation "com.dropbox.mobile.store:store4:4.0.5"

implementation "com.google.android.material:material:1.2.1"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ protected void onCreate(Bundle savedInstanceState) {

RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
.encryptionKey(key)
.allowQueriesOnUiThread(true)
.allowWritesOnUiThread(true)
.build();

// Start with a clean slate every time
Expand Down
2 changes: 1 addition & 1 deletion examples/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-rc-2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import io.realm.OrderedRealmCollectionChangeListener;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import io.realm.RealmResults;
import io.realm.Sort;
import io.realm.examples.intro.model.Cat;
Expand Down Expand Up @@ -66,7 +67,10 @@ protected void onCreate(Bundle savedInstanceState) {
Realm.deleteRealm(Realm.getDefaultConfiguration());

// Create the Realm instance
realm = Realm.getDefaultInstance();
RealmConfiguration build = new RealmConfiguration.Builder()
.allowWritesOnUiThread(true)
.allowQueriesOnUiThread(true).build();
realm = Realm.getInstance(build);

// Asynchronous queries are evaluated on a background thread,
// and passed to the registered change listener when it's done.
Expand Down
2 changes: 0 additions & 2 deletions examples/kotlinExample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ realm {
kotlinExtensionsEnabled = true
}


// enable @ParametersAreNonnullByDefault annotation. See https://blog.jetbrains.com/kotlin/2017/09/kotlin-1-1-50-is-out/
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
Expand All @@ -48,6 +47,5 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
}

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${kotlin_version}"
implementation "org.jetbrains.anko:anko-commons:0.10.4"
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import android.util.Log
import android.widget.LinearLayout
import android.widget.TextView
import io.realm.Realm
import io.realm.RealmConfiguration
import io.realm.Sort
import io.realm.examples.kotlin.model.Cat
import io.realm.examples.kotlin.model.Dog
Expand All @@ -46,6 +47,13 @@ class KotlinExampleActivity : Activity() {
rootLayout = findViewById(R.id.container)
rootLayout.removeAllViews()

Realm.setDefaultConfiguration(
RealmConfiguration.Builder()
.allowQueriesOnUiThread(true)
.allowWritesOnUiThread(true)
.build()
)

// Open the realm for the UI thread.
realm = Realm.getDefaultInstance()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import io.realm.examples.librarymodules.model.Elephant;
import io.realm.examples.librarymodules.model.Lion;
import io.realm.examples.librarymodules.model.Zebra;
import io.realm.examples.librarymodules.modules.AllAnimalsModule;
import io.realm.examples.librarymodules.modules.DomesticAnimalsModule;
import io.realm.examples.librarymodules.modules.ZooAnimalsModule;
import io.realm.exceptions.RealmException;
Expand All @@ -58,20 +59,29 @@ protected void onCreate(Bundle savedInstanceState) {
// The default Realm instance implicitly knows about all classes in the realmModuleAppExample Android Studio
// module. This does not include the classes from the realmModuleLibraryExample AS module so a Realm using this
// configuration would know about the following classes: { Cow, Pig, Snake, Spider }
RealmConfiguration defaultConfig = new RealmConfiguration.Builder().build();
RealmConfiguration defaultConfig = new RealmConfiguration
.Builder()
.modules(Realm.getDefaultModule(), new AllAnimalsModule())
.allowQueriesOnUiThread(true)
.allowWritesOnUiThread(true)
.build();

// It is possible to extend the default schema by adding additional Realm modules using modules(). This can
// also be Realm modules from libraries. The below Realm contains the following classes: { Cow, Pig, Snake,
// Spider, Cat, Dog }
RealmConfiguration farmAnimalsConfig = new RealmConfiguration.Builder()
.name("farm.realm")
.modules(Realm.getDefaultModule(), new DomesticAnimalsModule())
.allowQueriesOnUiThread(true)
.allowWritesOnUiThread(true)
.modules(Realm.getDefaultModule(), new AllAnimalsModule())
.build();

// Or you can completely replace the default schema.
// This Realm contains the following classes: { Elephant, Lion, Zebra, Snake, Spider }
RealmConfiguration exoticAnimalsConfig = new RealmConfiguration.Builder()
.name("exotic.realm")
.allowQueriesOnUiThread(true)
.allowWritesOnUiThread(true)
.modules(new ZooAnimalsModule(), new CreepyAnimalsModule())
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public class Zoo {
public Zoo() {
realmConfig = new RealmConfiguration.Builder() // The app is responsible for calling `Realm.init(Context)`
.name("library.zoo.realm") // So always use a unique name
.modules(new AllAnimalsModule()) // Always use explicit modules in library projects
.allowQueriesOnUiThread(true)
.allowWritesOnUiThread(true)
.modules(new AllAnimalsModule())
// Always use explicit modules in library projects
.build();

// Reset Realm
Expand Down
7 changes: 4 additions & 3 deletions examples/mongoDbRealmExample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ apply plugin: 'kotlin-android-extensions'
apply plugin: 'realm-android'

android {
compileSdkVersion rootProject.sdkVersion
// androidx.lifecycle dependencies requires Android APIs 31 or later
compileSdkVersion 31
buildToolsVersion rootProject.buildTools

defaultConfig {
Expand Down Expand Up @@ -53,8 +54,8 @@ realm {
}

dependencies {
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.1.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation 'com.google.android.material:material:1.6.1'
implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,11 @@ public class MyApplication extends Application {
public void onCreate() {
super.onCreate();
Realm.init(this);
RealmConfiguration configuration = new RealmConfiguration.Builder().deleteRealmIfMigrationNeeded().build();
RealmConfiguration configuration = new RealmConfiguration.Builder()
.deleteRealmIfMigrationNeeded()
.allowWritesOnUiThread(true)
.allowQueriesOnUiThread(true)
.build();
Realm.setDefaultConfiguration(configuration);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public class MyApplication extends Application {
public void onCreate() {
super.onCreate();
Realm.init(this);
RealmConfiguration config = new RealmConfiguration.Builder().build();
RealmConfiguration config = new RealmConfiguration.Builder()
.allowWritesOnUiThread(true)
.allowQueriesOnUiThread(true)
.build();
Realm.deleteRealm(config);
Realm.setDefaultConfiguration(config);
createTestData();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public void onCreate() {

// Configure Realm for the application
Realm.init(this);
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder().build();
RealmConfiguration realmConfiguration = new RealmConfiguration.Builder()
.allowWritesOnUiThread(true)
.allowQueriesOnUiThread(true)
.build();
Realm.deleteRealm(realmConfiguration); // Clean slate
Realm.setDefaultConfiguration(realmConfiguration); // Make this Realm the default
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import android.widget.TextView;

import io.realm.Realm;
import io.realm.RealmConfiguration;
import io.realm.RealmResults;
import io.realm.examples.unittesting.model.Person;

Expand All @@ -43,7 +44,12 @@ protected void onCreate(Bundle savedInstanceState) {
rootLayout.removeAllViews();

// Open the default Realm for the UI thread.
realm = Realm.getDefaultInstance();
RealmConfiguration conf = new RealmConfiguration
.Builder()
.allowWritesOnUiThread(true)
.allowQueriesOnUiThread(true)
.build();
realm = Realm.getInstance(conf);

// Clean up from previous run
cleanUp();
Expand Down
Loading