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

Building Project creates a different DaoSession and DaoMaster on Windows vs Mac #880

Closed
JeckChou opened this issue Jun 28, 2018 · 14 comments
Assignees
Labels
Milestone

Comments

@JeckChou
Copy link

JeckChou commented Jun 28, 2018

when I compile my project , the files that DaoMaster and DaoSession will be changed even I have to do nothing with it. I`m puzzled by this change when I track them with git version control. what should I do to avoid it ?
any one can help me ? thanks

@wurensen
Copy link

The same to me.Compile on Mac.

@wurensen
Copy link

I decompile plugin classes, find that the reason of wrong sort is "Java File.class" creating File(is a directory) object depends on the PC Operate System. On windows, children of the directory File Object are sorted by dictionary, e.g A.java, B.java, C.java, etc.But on my macOS(version 10.13.5), there are B.java, C.java. A.java.
So I hope the greenDAO plugin can resort the java source files list before executing DetectEntityCandidatesTask.

@wurensen
Copy link

wurensen commented Jul 24, 2018

@JeckChou I develop a plugin resolved the problem.Just use it to replace the 'greendao-gradle-plugin'. https://github.com/wurensen/Greendao3GradlePlugin

@MappApp
Copy link

MappApp commented Jul 24, 2018

@wurensen thank you for your reply. you solve my problem. I`m develop on mac too. but from my partner, he is also face to the same problem with window system. it is strange

@JeckChou
Copy link
Author

@wurensen thanks for your help

@wurensen
Copy link

@MappApp Let your partner use my plugin and run the gradle task 'greendaoGenerate'

@greenrobot-team greenrobot-team changed the title DaoMaster & DaoSession changed every time when I compile Building Project creates a different DaoSession and DaoMaster on Windows vs Mac Aug 21, 2018
@greenrobot-team
Copy link
Collaborator

As a workaround you can try to set the daoPackage property in the greendao closure:

greendao {
    schemaVersion 6
    daoPackage "com.example.model"
}

This way greenDAO won't choose a package automatically.
-ut

@wurensen
Copy link

@greenrobot-team It doesn't work.At first my team set 'daoPackage'.

@greenrobot-team
Copy link
Collaborator

@wurensen What does not work? Are the generated classes still in another package? -ut

@wurensen
Copy link

wurensen commented Aug 27, 2018

@greenrobot-team I mean the contents of 'DaoMaster.java' aren't sorted by dictionary.

@JeckChou
Copy link
Author

@greenrobot-team I am not means the generated classes in different package , it was said that the generated DaoSession class and DaoMaster class implementation is changed. eg.
first compile
AxxDao.createTable(); BxxDao.createTable();
second
BxxDao.createTable(); AxxDao.createTable();
in DaoMaster

@greenrobot-team greenrobot-team added this to the 3.x milestone Aug 28, 2018
@manisoft83
Copy link

If we use 'daoPackage "com.example.model"' than it is ignoring all subfolders.
e.g., Ignoring sub folder when we have entity under "com.example.model.test.TestModel", TestModelDAO is getting created under "com.example.model".

@greenrobot-team
Copy link
Collaborator

This issue was fixed internally (imports are now always sorted) and will be available with the next update.

Note: Anyhow I recommend generating the greenDAO classes on-demand into the build folder and removing them from source control. E.g. remove targetGenDir from the greendao options in build.gradle.

@greenrobot-team greenrobot-team self-assigned this Jul 16, 2019
@greenrobot-team greenrobot-team modified the milestones: 3.x, 3.3.0 Feb 18, 2020
@greenrobot-team
Copy link
Collaborator

3.3.0 has been released which should fix this issue.
https://greenrobot.org/greendao/changelog/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants