Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

greenDAO schema generation with relative output path; failing with i/o not found

Following along with this tutorial, I've been able to create a working app module that compiles and runs, but fails if I pass a relative path to the generateAll method. It works fine if I specify an absolute path. My android studio project is composed of a few modules, structured like

project_root, with sub directories for each of it's modules

/daogenerator

/app

Each has it's own src directories, and I'm calling the generateAll like:

new DaoGenerator().generateAll(schema,
                "../app/src");

which results in an io error, indicating that the directory doesn't exist. I've modified the path to many reasonable alternatives, and confirmed that the paths exist on disk, but still getting the error. The absolute path works fine, so I'm trying to understand what I'm missing to get it working with a relative path. Thanks.

like image 455
wkhatch Avatar asked Feb 13 '23 04:02

wkhatch


2 Answers

The outDir parameter is expected to be relative to the project directory.

For example, suppose your MyDaoGenerator class is in module1 under projectA and you want to generate the DAO classes into a separate module2 of the same project ...

projectA
    module1/
        src/main/java/com.my.package/MyDaoGenerator.java
    module2/
        src/main/java/      <-- target directory

... the outDir parameter would be module2/src/main/java.

like image 195
Jack Straw Avatar answered May 10 '23 02:05

Jack Straw


In my case I had to change the package to this

 new DaoGenerator().generateAll(schema, "app/src/main/java");

from this

new DaoGenerator().generateAll(schema, "../app/src/main/java");
like image 20
Mightian Avatar answered May 10 '23 02:05

Mightian