Open zhenian opened 6 years ago
@greenrobot-team
I want to fix this bug. But Where is the Gradle plugin source code?
from #412
As the error message indicates, your constructors have changed in between runs.
Have a look at the docs on how to resolve this: http://greenrobot.org/greendao/documentation/modelling-entities/#Modifying_generated_code
Closing. Please re-open if you can verify (example code) that this is indeed an issue with the plugin. -ut
@greenrobot-team
I make a litter demo for this bug: [ReplayBug4GreenDAOPlugin]
(https://github.com/zhenian/ReplayBug4GreenDAOPlugin) https://github.com/zhenian/ReplayBug4GreenDAOPlugin
Rebuild project
. first, it is ok.Rebuild project
again. replay this bug.We (Gradle core team) also found this issue. Seems like when two subprojects both apply greendao plugin and enable --parallel
(which may execute tasks in order :subproject1:greendaoPrepare
-> :subproject2:greendaoPrepare
->:subproject1:greendao
->:subproject2:greendao
or simultaneously), this issue will occur on second execution.
Thanks @zhenian for the reproducible sample. One workaround I found is "simulating" serailization execution:
diff --git a/app/build.gradle b/app/build.gradle
index d5f1684..3055caf 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -1,5 +1,3 @@
-apply plugin: 'com.android.application'
-apply plugin: 'org.greenrobot.greendao'
android {
compileSdkVersion 28
diff --git a/app2/build.gradle b/app2/build.gradle
index ade9fe9..1d91245 100644
--- a/app2/build.gradle
+++ b/app2/build.gradle
@@ -1,5 +1,4 @@
-apply plugin: 'com.android.application'
-apply plugin: 'org.greenrobot.greendao'
+
android {
compileSdkVersion 28
diff --git a/build.gradle b/build.gradle
index 79ddbab..859ec75 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
-
+
repositories {
maven { url "http://maven.aliyun.com/nexus/content/groups/public" }
google()
@@ -17,6 +17,24 @@ buildscript {
}
}
+def greendaoTasks = []
+
+subprojects { subproject ->
+ apply plugin: 'com.android.application'
+ apply plugin: 'org.greenrobot.greendao'
+ afterEvaluate {
+ greendaoTasks.add(subproject.tasks.findByName('greendaoPrepare'))
+ greendaoTasks.add(subproject.tasks.findByName('greendao'))
+
+ if (greendaoTasks.size() == 4) {
+ println(greendaoTasks)
+ for (int i = 1; i < 4; ++i) {
+ greendaoTasks[i].mustRunAfter(greendaoTasks[i - 1])
+ }
+ }
+ }
+}
+
allprojects {
repositories {
maven { url "http://maven.aliyun.com/nexus/content/groups/public" }
My speculation is greendao plugin lacks proper synchronization between different subproject. I'd like to see the plugin source code very much.
@zhenian can you please reopen this issue?
@greenrobot-team had closed this issue so I have no right to reopen it.
@greenrobot-team , can you recheck this issue?
Add a new issue and reference to this issue
Well, AFAIK the author can reopen it, unless this issue is locked. Maybe I'm wrong.
I thought so too, sorry, reopening.
However, can not reproduce using the given example project updated to Gradle 4.10.2.
@zhenian As @blindpirate suggested this may be due to Gradle parallel mode. Do you have org.gradle.parallel=true
set in your global gradle.properties
file?
I see it commented out in the projects gradle.properties
file. If I uncomment I can reproduce the above error.
Maybe try to explicitly disable parallel mode by adding org.gradle.parallel=false
to your projects gradle.properties
.
edit: You mention parallel execution in the title, so that must be it. -ut
I can reproduce with the given sample by running ./gradlew assemble --parallel
twice. I think @zhenian might forget to enable org.gradle.parallel=true
in the sample project.
BTW, org.gradle.parallel=false
is default value, you don't have to set it explicitly.
We don't generally want to recommend disabling parallel mode because it can really slow down a build. After all, my machine alone has 8 cores. Do I want 7 of them doing nothing during a build?
Putting the following into the root build.gradle
(and with parallel=true) fixes the sample project:
def greenDaoTasks = []
subprojects { subproject ->
apply plugin: 'org.greenrobot.greendao'
afterEvaluate {
greenDaoTasks.add(subproject.tasks.findByName('greendaoPrepare'))
greenDaoTasks.add(subproject.tasks.findByName('greendao'))
if (greenDaoTasks.size() > 2) {
println greenDaoTasks
for (int i = 1; i < greenDaoTasks.size(); i++) {
greenDaoTasks[i].mustRunAfter(greenDaoTasks[i - 1])
}
}
}
}
You can now run ./gradlew assembleDebug && ./gradlew assembleDebug
and the build does not fail. It's ugly as hell, though.
Is there a plan to fix this bug?
if no, is there a plan to release Gradle plugin Source codes? #412
Is there a plan to fix this bug?
if no, is there a plan to release Gradle plugin Source codes?
Background
In a gradle project, there are two apps which use greenDAO. Define in
settings.gradle
:in
:app
and:app2
, there are some same classes defined at packagecom.xxx.model
which mark with@org.greenrobot.greendao.annotation.Entity
. Same name, same fields.Issue
when I build or clean with commands:
./gradlew :app:assembleDebug
./gradlew :app:greendao
./gradlew :app1:assembleDebug
./gradlew :app1:greendao
It is ok.
but, when I make
Clean Project
with Android Studio, there is a error.gradle task seqs:
error message: