GreenDAO circuit generation with relative output; failure with i / o not found

Following along with this tutorial , I was able to create a working module for the application that compiles and runs, but fails if I pass the relative path to the generateAll method. It works fine if I point the absolute path. My Android studio project consists of several modules, structured as

project_root, with subdirectories for each of the modules

/ daogenerator

/attachment

Each has its own src directories, and I call generateAll as:

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

resulting in an io error indicating that the directory does not exist. I changed the path to many reasonable alternatives and confirmed that the paths exist on the disk but still get the error. The absolute path works fine, so I'm trying to figure out what I am missing to make it work with the relative path. Thank you

+4
source share
3 answers

It is expected that the parameter outDirwill refer to the project directory.

For example, suppose your class MyDaoGeneratoris in module1a section projectA, and you want to generate DAO classes in a separate of module2the same project ...

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

... the parameter outDirwill be module2/src/main/java.

+5
source

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

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

, .

If your dao generator code is in a class named M.java, you can edit its configuration:

enter image description here

Then you must make sure that it points to the correct working directory:

enter image description here

Finally, we can generate the dao code:

public static void main(String[] args) throws Exception
{
    ...
    new DaoGenerator().generateAll(schema, "."); // direct to working directory
}

It worked for me. Hope this helps.

Source: this tutorial

+1
source

Source: https://habr.com/ru/post/1536832/


All Articles