Devskiller / jpa2ddl

JPA Schema Generator Plugin
Apache License 2.0
110 stars 33 forks source link

Problem with gradle plugin 0.9.9 under windows10 #14

Closed gpaglia closed 6 years ago

gpaglia commented 6 years ago

Hello, I installed the gradle plugin v 0.9.9 under windows 10 (Eclipse Oxygen,w/buildship) and I get the exception belo, in the dll generation task as the plugn is getting a FileSystemException on a file: \D\DiskZ_new\Private-Project-Folder\gmoney\gmoney-master\gmoney-jpa\build\classes\java\main\org\jfin\gmoney\jpa\persistence

Isn't the URL structure incorrect? I mean, shouldn't it be something like ///D:/DiskZ_new/Private-Project-Foler...??

Thanks for the support, Gianni

Stack trace: `* Exception is: org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':gmoney-jpa:generateDdl'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62) at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97) at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87) at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98) at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625) at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) Caused by: org.gradle.api.UncheckedIOException: java.nio.file.FileSystemException: \D\DiskZ_new\Private-Project-Folder\gmoney\gmoney-master\gmoney-jpa\build\classes\java\main\org\jfin\gmoney\jpa\persistence: Impossibile trovare il percorso di rete.

at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:57)
at org.gradle.internal.UncheckedException.throwAsUncheckedException(UncheckedException.java:40)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:76)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:142)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:135)
at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:122)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:762)
at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:729)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336)
at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92)
... 28 more

Caused by: java.nio.file.FileSystemException: \D\DiskZ_new\Private-Project-Folder\gmoney\gmoney-master\gmoney-jpa\build\classes\java\main\org\jfin\gmoney\jpa\persistence: Impossibile trovare il percorso di rete.

at com.devskiller.jpa2ddl.FileResolver.listClassNamesInPackage(FileResolver.java:77)
at com.devskiller.jpa2ddl.SchemaGenerator.generate(SchemaGenerator.java:80)
at com.devskiller.jpa2ddl.GenerateTask.generateModel(GenerateTask.java:37)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
... 40 more

`

jkubrynski commented 6 years ago

Thanks for the report - could you please include the plugin configuration from your build.gradle?

gpaglia commented 6 years ago

I attach below the project's build.gradle and the master project's build.gradle.

Thanks a lot again, Gianni.

The project's build.gradle:

/*
 * This build file was generated by the Gradle 'init' task.
 *
 * This generated file contains a sample Java Library project to get you started.
 * For more details take a look at the Java Libraries chapter in the Gradle
 * user guide available at https://docs.gradle.org/4.2.1/userguide/java_library_plugin.html
 */

// Jar info
jar {
    baseName = 'gmoney-jpa'
    version =  '0.1.0'
}

// for dll stripts generation
apply plugin: 'com.devskiller.jpa2ddl'

jpa2ddl {
    packages = ['org.jfin.gmoney.jpa.persistence']
    // generationMode = 'DATABASE'
    // action = 'CREATE'
}

dependencies {

    compile project(":gmoney-persistenceapi")
    compile project(":gmoney-serviceapi")
    compile project(":gmoney-library")

    // spring modules
    compile 'org.springframework:spring-context'
    compile 'org.springframework:spring-orm'
    compile 'org.springframework.data:spring-data-jpa'

    // apache dbcp2 
    compile 'org.apache.commons:commons-dbcp2'

    // compile "org.flywaydb:flyway-core"       // :4.1.2"

    compile "org.apache.derby:derby"        // :10.13.1.1"  
    compile "com.h2database:h2"             // :
    // compile "commons-beanutils:commons-beanutils:1.9.3"

        // https://mvnrepository.com/artifact/org.hibernate/hibernate-java8
    compile group: 'org.hibernate', name: 'hibernate-java8'
    // Hibernate jpa metamodel generator
    compile group: 'org.hibernate', name: 'hibernate-jpamodelgen'

    // jackson java 8 datatypes
    // DEPRECATED -- compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310'
    compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jdk8'

}

// jpaModelgen static metamodel
apply plugin: "at.comm_unity.gradle.plugins.jpamodelgen"
jpaModelgen {
    library = "org.hibernate:hibernate-jpamodelgen:${dependencyManagement.compile.importedProperties['hibernate.version']}"
    jpaModelgenSourcesDir = "src/jpaModelgen/java"
    }

compileJava.options.compilerArgs += ["-proc:none", "-AfullyAnnotationConfigured=true"]

// copy jpaModelgen processor to lib directory 
configurations {
    modelgen
}

dependencies {
    modelgen "org.hibernate:hibernate-jpamodelgen:${dependencyManagement.compile.importedProperties['hibernate.version']}@jar"
}

task copyModelgenProcessor(type: Copy) {
    from configurations.modelgen
    into "$projectDir/lib"
    rename { String filename -> 'hibernate-jpamodelgen-STD.jar' }
}`

The master project's build.gradle:
`       mavenLocal()
    }

}

subprojects {

    apply plugin: 'java'
    // apply plugin: 'org.springframework.boot'
    apply plugin: 'io.spring.dependency-management'

    sourceCompatibility = 1.8
    targetCompatibility = 1.8

    [compileJava, compileTestJava]*.options.collect {options ->

        options.compilerArgs.add '-parameters'
      }
/*  
    tasks.withType(JavaCompile) {
        println 'Compiler args in ' + project.name + ' : ' + options.compilerArgs
    }
*/

/*      
    compileJava {
        options.compilerArgs += ["-parameters"]
    }

    compileTestJava {
        options.compilerArgs += ["-parameters"]
    }

    tasks.withType(JavaCompile) {
        println 'Compiler args in ' + project.name + ' : ' + options.compilerArgs
    }
*/

    task sourceJar(type: Jar) {
        from sourceSets.main.allJava
        classifier "source"
    }

    // In this section you declare where to find the dependencies of your project
    repositories {
        // Ivy local repo
        ivy {
            name "localRepo"
            url 'D:/DiskZ_new/Private-Repo-ivy'
        }

        maven {
            name "springMilestonesRepo"
            url "https://repo.spring.io/libs-milestone"
        }

        // spring
        maven { url "https://repo.spring.io/snapshot" }
        maven { url "https://repo.spring.io/milestone" }
        maven { url "https://repo.spring.io/release" }

        // Use 'jcenter' for resolving your dependencies.
        jcenter()

        // Also maven central
        mavenCentral()

        // for ghostdriver
        maven {
            name "jitpack.io"
            url "https://jitpack.io"
        }
    }

    publishing {
        repositories {
            mavenLocal()
        }
        publications {
            mavenJava(MavenPublication) {
                from components.java

                artifact sourceJar {
                    classifier "sources"
                }
            }
        }
    }

    dependencyManagement {
        imports {
            // mavenBom 'org.springframework.data:spring-data-releasetrain:Ingalls-SR1'
            mavenBom("org.springframework.boot:spring-boot-dependencies:${springBootVersion}")
        }

        dependencies {

            // javax JSON api
            dependency  "javax.json:javax.json-api:1.0"

            // Json provider
            dependency "org.glassfish:javax.json:1.0.4"

            // Spring security -- temporary until migration to Spring Security finishes
            dependency group: 'org.springframework.security.oauth', name: 'spring-security-oauth2', version: '2.2.0.RELEASE'
            // Spring statemachine
            dependency group: 'org.springframework.statemachine', name: 'spring-statemachine-core', version: '1.2.5.RELEASE'
            dependency group: 'org.springframework.statemachine', name: 'spring-statemachine-test', version: '1.2.5.RELEASE'

            // selenium
            dependency group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '3.6.0' //'2.53.1'
            dependency group: 'org.seleniumhq.selenium', name: 'selenium-support', version: '3.6.0' //'2.53.1'
            dependency group: 'org.seleniumhq.selenium', name: 'htmlunit-driver', version: '2.27'
            // htmlunit
            dependency group: 'net.sourceforge.htmlunit', name: 'htmlunit', version: '2.27'

            // ghostdriver
            dependency group: 'com.github.detro', name: 'ghostdriver', version:'2.1.0'

            // https://mvnrepository.com/artifact/de.roskenet/springboot-javafx-support
            dependency group: 'de.roskenet', name: 'springboot-javafx-support', version: '1.4.1-gp-v3'

            // https://mvnrepository.com/artifact/de.roskenet/springboot-javafx-test
            dependency group: 'de.roskenet', name: 'springboot-javafx-test', version: '1.0.1'

            // https://mvnrepository.com/artifact/org.controlsfx/controlsfx
            dependency group: 'org.controlsfx', name: 'controlsfx', version: '8.40.14'

            // https://mvnrepository.com/artifact/com.auth0/java-jwt
            dependency group: 'com.auth0', name: 'java-jwt', version: '3.2.0'

            // apache httpclient to use in Speing resttemplate to enable patch verbs
            dependency group: 'org.apache.httpcomponents', name: 'httpclient', version:'4.5.3'

            // spring security jwt
            dependency group: 'org.springframework.security', name: 'spring-security-jwt', version: '1.0.8.RELEASE'

            // https://mvnrepository.com/artifact/com.google.guava/guava
            dependency group: 'com.google.guava', name: 'guava', version: '23.6-jre'

        }
    }

    // In this section you declare the dependencies for your production and test code
    dependencies {

        // The production code uses the SLF4J logging API at compile time
        // compile 'org.slf4j:slf4j-api:1.7.24'
        compile 'org.slf4j:slf4j-api'

        // replace jcl because we exclude jcl from spring core
        // compile 'org.slf4j:jcl-over-slf4j:1.7.24'
        compile 'org.slf4j:jcl-over-slf4j'

        // logback classic and core
        // compile "ch.qos.logback:logback-classic:1.2.1"
        // compile "ch.qos.logback:logback-core:1.2.1"          // should be redundant ...
        compile "ch.qos.logback:logback-classic"
        compile "ch.qos.logback:logback-core"           // should be redundant ...

        // javax JSON api
        compile "javax.json:javax.json-api"

        // Common spring
        compile("org.springframework:spring-core") { // :${rootProject.ext.springFrameworkVersion}") {
            // exclude commons-logging from spring core
            exclude group: 'commons-logging', module: 'commons-logging'
        }
        compile ("org.springframework:spring-beans")    // :${springFrameworkVersion}"
        compile ("org.springframework:spring-test")     // :${springFrameworkVersion}"
        compile ("org.springframework:spring-context")  // :${springFrameworkVersion}"
        compile ("org.springframework:spring-context-support")  // :${springFrameworkVersion}" 

        // Json provider
        compile ("org.glassfish:javax.json")    

        // https://mvnrepository.com/artifact/com.github.reinert/jjschema
        // compile("com.github.reinert:jjschema:${jjSchemaVersion}")

        // https://mvnrepository.com/artifact/com.kjetland/mbknor-jackson-jsonschema_2.12
        // compile group: 'com.kjetland', name: 'mbknor-jackson-jsonschema_2.12', version: "${jsonSchemaV4Version}"

        // Declare the dependency for your favourite test framework you want to use in your tests.
        // TestNG is also supported by the Gradle Test task. Just change the
        // testCompile dependency to testCompile 'org.testng:testng:6.8.1' and add
        // 'test.useTestNG()' to your build script.

        testCompile ('junit:junit')

        // mockito 2.7.18
        testCompile ('org.mockito:mockito-core')    // :2.7.18'

        // https://mvnrepository.com/artifact/org.hamcrest/hamcrest-all
        testCompile group: 'org.hamcrest', name: 'hamcrest-core' /* , version: '1.3' */
        testCompile group: 'org.hamcrest', name: 'hamcrest-library' /* , version: '1.3' */

    }
}
jkubrynski commented 6 years ago

@gpaglia could you please build the gradle plugin from master and check if your issue has been solved? Unfortunately I have no access to windows machine to verify the fix

gpaglia commented 6 years ago

Hello Jakub, Yes, sure, I'll build from the repo and let you know, it will take me a few days as I will be out travelling until Friday.

Meanwhile I really thank you for your support and help, Gianni

Il 15 gen 2018 11:55 PM, "Jakub Kubryński" notifications@github.com ha scritto:

@gpaglia https://github.com/gpaglia could you please build the gradle plugin from master and check if your issue has been solved? Unfortunately I have no access to windows machine to verify the fix

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Devskiller/jpa2ddl/issues/14#issuecomment-357807509, or mute the thread https://github.com/notifications/unsubscribe-auth/AGyfPJLJGGpsyUZmT4Ulpxytkuy4XGh5ks5tK9dxgaJpZM4RdU3r .

gpaglia commented 6 years ago

Hello Jakub, I tested the new snapshot and it goes better, but still has 3 problems, 2 of which I corrected, the third I think I understood the root cause of.

  1. In jpa2dll-core DatabaseSchemaUpdateTest Files.copy(Paths.get(getClass().getClassLoader().getResource("sample_migration/v1__jpa2ddl_init.sql").getPath()), outputPath.toPath().resolve("v1__jpa2ddl_init.sql")); should be, instead: Files.copy(Paths.get(getClass().getClassLoader().getResource("sample_migration/v1__jpa2ddl_init.sql").toURI()), outputPath.toPath().resolve("v1__jpa2ddl_init.sql"));

otherwise, at least on a Windows system, you'll get complaints about a ':' character in the path name

  1. In the pom of jpa2dll-gradle-plugin, the exec block, for a windows system, should be something like `

    org.codehaus.mojo
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.6.0</version>
            <executions>
                <execution>
                    <id>gradle</id>
                    <phase>package</phase>
                    <configuration>
                        <executable>cmd</executable>
    
                        <arguments>
                            <argument>/c</argument>
                            <argument>"${project.basedir}/gradlew.bat"</argument>
                            <argument>clean</argument>
                            <argument>build</argument>
                            <argument>-Pjpa2ddlVersion=${project.version}</argument>
                        </arguments>
                    </configuration>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>`

as you don't have an executable gradlew but instead a gradlew.bat which must be executed via cmd /c I'm sure there is a way to set up some conditional configuration dependent on the OS, but I don't know maven well enough...

  1. I have one entity structured like this: ` @Entity @DiscriminatorValue("CONTAINER") @Access(AccessType.FIELD) public class ContainerAccount extends Account{

    @OneToMany(mappedBy = "parentAccount", cascade = CascadeType.ALL, orphanRemoval = true) private List accounts = new ArrayList<>();

    protected ContainerAccount() { super(); }

    public ContainerAccount( UUID id, String name, AccountType accountType, Currency currency) { super(id, name, accountType, currency); }

    public List getAccounts() { return accounts; }

    public void addAccount(Account account) { if (! accounts.contains(account)) { account.setParentAccountLocal(this); accounts.add(account); } else { throw new IllegalArgumentException("Duplicate account " + account.getName() + "in parent"); } }

    public void removeAccount(Account account) { if (accounts.contains(account)) { accounts.remove(account); account.setParentAccountLocal(null); } else { throw new IllegalArgumentException("Account " + account.getName() + " not found in parent"); } }

    // Business logic

    public IMultiBalance getMultiBalance() { IMultiBalance mb = new MultiBalance();

    for (Account a : accounts) {
        if (a.getAccountType().isContainer()) {
            ContainerAccount ca = (ContainerAccount) a;
            mb = mb.add(ca.getMultiBalance());
        } else {
            mb = mb.add(a.getCurrency().getId(), a.getBalance());
        }
    }
    
    return mb;

    }

}`

which has a behaviour method returning a MultiBalance type (which is an immutable, non-entity type defined in an external project/library).

MultiBalance implements the IMultiBalance interface which is defined in yet another project/library where I have just the API types.

The jpa2dll gradle task then gets a NoClassDefFoundError from Hibernate complaining that the ContainerAccount class cannot be loaded because the IMultiBalance class is not known.

Consider that I have taken the code of your plugin and reworked it as a simple java app that I can execute from the project context (eclipse - run as java application) and it works perfectly, so I imagine that, when the code executes in the context of the gradle plugin, the classpath does not include the api-only external library.

Anyays, maybe to cover for a case like this the plugin settings should also include a classpath parameter where one can customie the classpath in effect in the context of the gradle plugin execution.

I attach below the exception stack trace in case it can help you understand, org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':gmoney-jpa:generateDdl'. at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:100) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:70) at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62) at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58) at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:97) at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:87) at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52) at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.run(DefaultTaskGraphExecuter.java:248) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:241) at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:230) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.processTask(DefaultTaskPlanExecutor.java:123) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.access$200(DefaultTaskPlanExecutor.java:79) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:104) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:98) at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.execute(DefaultTaskExecutionPlan.java:625) at org.gradle.execution.taskgraph.DefaultTaskExecutionPlan.executeWithTask(DefaultTaskExecutionPlan.java:580) at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$TaskExecutorWorker.run(DefaultTaskPlanExecutor.java:98) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) Caused by: org.hibernate.boot.registry.classloading.spi.ClassLoadingException: Unable to load class [org.jfin.gmoney.jpa.persistence.ContainerAccount] at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:351) at org.hibernate.boot.model.source.internal.annotations.AnnotationMetadataSourceProcessorImpl.<init>(AnnotationMetadataSourceProcessorImpl.java:104) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess$1.<init>(MetadataBuildingProcess.java:147) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:141) at org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:83) at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:418) at org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:87) at org.hibernate.boot.MetadataSources.buildMetadata(MetadataSources.java:179) at com.devskiller.jpa2ddl.SchemaGenerator.generate(SchemaGenerator.java:96) at com.devskiller.jpa2ddl.GenerateTask.generateModel(GenerateTask.java:38) at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:142) at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:135) at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:122) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:762) at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:729) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter$1.run(ExecuteActionsTaskExecuter.java:121) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:110) at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:92) ... 28 more Caused by: java.lang.NoClassDefFoundError: org/jfin/gmoney/serviceapi/balance/IMultiBalance at org.hibernate.boot.registry.classloading.internal.ClassLoaderServiceImpl.classForName(ClassLoaderServiceImpl.java:345) ... 50 more Caused by: java.lang.ClassNotFoundException: org.jfin.gmoney.serviceapi.balance.IMultiBalance ... 51 more

This is as far as I got as of now, G

gpaglia commented 6 years ago

... I forgot one point: the jpa2dll-maven-plugin subproject did not build in the beginning, because of missing takari/mojos.xml.

I am not familiar with building maven plugins, but I think I have understood that this file is actually generated by the build itself, infact I fould it in the target/classes, so I copied it into the META-INF directory and it actually worked. I don't know what should be the correct way of generating it, though...

G

gpaglia commented 6 years ago

Hello @jkubrynski , I have a version of the plugin working in my WIndows 10 environment, it can be accessed at https://github.com/gpaglia/jpa2ddl, I created a branch 0.9.10-gp.

In summary, I changed the following:

to have all project dependencies in the URLClassloader classpath.

Hope this can be useful to others, Gianni

jkubrynski commented 6 years ago

Awesome! 👍 Could you please create a PR?

gpaglia commented 6 years ago

Sure, I'll do it today. Gianni

Il 22 gen 2018 12:47 PM, "Jakub Kubryński" notifications@github.com ha scritto:

Awesome! 👍 Could you please create a PR?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Devskiller/jpa2ddl/issues/14#issuecomment-359400781, or mute the thread https://github.com/notifications/unsubscribe-auth/AGyfPGxTcRMmONlY-fSJEFi8GuUG4BAXks5tNHVLgaJpZM4RdU3r .

jkubrynski commented 6 years ago

It's released in 0.9.10 - could you please check @gpaglia if it works correctly?

jkubrynski commented 6 years ago

@gpaglia Could you please confirm the fix works?

gpaglia commented 6 years ago

Jakub, I was testing the 0.9.10 release just today.

In the gradle-plugin I still see the problem related to Hibernate complaining, during schema generation, about unknown classes related to interfaces implemented by the entity classes and defined in external jars.

Looking at the code of 0.9.10, I see that, in the jpa2ddl-gradle-plugn GeneratePlugin class, in line 39, the class path used to build the URLClassLoader is created referencing only the main sourceset, which means, as I understand it, that the external jars that are set as Project dependencies are not included.

In my PR (which works OK in my environment,) I just changed line 39-42 to simply: paths = mainClasspath.getFiles(); to include all files on the Project classPath.

Today I have verified (increasing the trace level of Hibernate) that during schema generation, Hibernate logs all classes and interfaces referenced by annotated entity classes as types to be included in the schema generation process.

Hope this helps, G

Da: Jakub Kubryński Inviato: domenica 28 gennaio 2018 18:19 A: Devskiller/jpa2ddl Cc: Gian Enrico Paglia; Mention Oggetto: Re: [Devskiller/jpa2ddl] Problem with gradle plugin 0.9.9 underwindows10 (#14)

@gpaglia Could you please confirm the fix works? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

jkubrynski commented 6 years ago

The problem with all files is that it includes all dependencies and there will be a lot of scanning. So maybe directories and .class files should be included?

gpaglia commented 6 years ago

Yes, you are right

Probably an explicit configuration parameter could be added to be set in the jpa2ddl extension configuration to explicitly configure the files to be selectively added to the classpath for generation.

That would keep the process lean and add additional processing only for the external jars that are specifically needed.

G

Da: Jakub Kubryński Inviato: domenica 28 gennaio 2018 18:46 A: Devskiller/jpa2ddl Cc: Gian Enrico Paglia; Mention Oggetto: Re: [Devskiller/jpa2ddl] Problem with gradle plugin 0.9.9 underwindows10 (#14)

The problem with all files is that it includes all dependencies and there will be a lot of scanning. So maybe directories and .class files should be included? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

jkubrynski commented 6 years ago

Could you please attach your windows classpath returned by mainClasspath.getFiles()?

gpaglia commented 6 years ago

Yes OK, in a few hours I’ll get you the info, I’m now working on another Project.

G

Da: Jakub Kubryński Inviato: domenica 28 gennaio 2018 19:04 A: Devskiller/jpa2ddl Cc: Gian Enrico Paglia; Mention Oggetto: Re: [Devskiller/jpa2ddl] Problem with gradle plugin 0.9.9 underwindows10 (#14)

Could you please attach your windows classpath returned by mainClasspath.getFiles()? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

gpaglia commented 6 years ago

Hi Jakub,

this is the code I have now (taken from 0.9.10):

paths = mainClasspath.getFiles(); System.out.println("path = mainClasspath.getFiles() returns: "); System.out.println(paths.toString());

paths = mainClasspath.getFiles().stream() .filter(File::isDirectory) .collect(Collectors.toSet());

System.out.println("after filtering, path is: "); System.out.println(paths.toString());

The printout is in the attached txt.

Regards, G

Da: Jakub Kubryński Inviato: domenica 28 gennaio 2018 19:04 A: Devskiller/jpa2ddl Cc: Gian Enrico Paglia; Mention Oggetto: Re: [Devskiller/jpa2ddl] Problem with gradle plugin 0.9.9 underwindows10 (#14)

Could you please attach your windows classpath returned by mainClasspath.getFiles()? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

*** Before filtering path = mainClasspath.getFiles() returns: [D:\DiskZ_new\Private-Project-Folder\gmoney\gmoney-master\gmoney-jpa\build\classes\java\main, D:\DiskZ_new\Private-Project-Folder\gmoney\gmoney-master\gmoney-jpa\build\resources\main, D:\DiskZ_new\Private-Project-Folder\gmoney\gmoney-master\gmoney-persistenceapi\build\libs\gmoney-persistenceapi-0.1.0.jar, D:\DiskZ_new\Private-Project-Folder\gmoney\gmoney-master\gmoney-library\build\libs\gmoney-library-0.1.0.jar, D:\DiskZ_new\Private-Project-Folder\gmoney\gmoney-master\gmoney-serviceapi\build\libs\gmoney-serviceapi-0.1.0.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.slf4j\jcl-over-slf4j\1.7.25\f8c32b13ff142a513eeb5b6330b1588dcb2c0461\jcl-over-slf4j-1.7.25.jar, D:\DiskZ_new\Private-Repo.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.springframework.data\spring-data-jpa\2.0.2.RELEASE\87ab35c6913a55acade27592161d3b7a543c68a9\spring-data-jpa-2.0.2.RELEASE.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.springframework.data\spring-data-commons\2.0.2.RELEASE\1befa3239976b856202b1735531910a0c2f4e17f\spring-data-commons-2.0.2.RELEASE.jar, D:\DiskZ_new\Private-Repo.m2\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar, D:\DiskZ_new\Private-Repo.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar, D:\DiskZ_new\Private-Repo.m2\repository\javax\json\javax.json-api\1.0\javax.json-api-1.0.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.springframework\spring-context-support\5.0.2.RELEASE\f3dcba6050b1635aacc606243decc99515d1430\spring-context-support-5.0.2.RELEASE.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.springframework\spring-context\5.0.2.RELEASE\743a5f6d94a8af5759e6e70c360a7b4a47a704c\spring-context-5.0.2.RELEASE.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.springframework\spring-orm\5.0.2.RELEASE\59f207a8426f6090734663afcd6d6003cca57ce8\spring-orm-5.0.2.RELEASE.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.springframework\spring-aop\5.0.2.RELEASE\4d49aa2cff33be79da99413e28a905898600ccaa\spring-aop-5.0.2.RELEASE.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.springframework\spring-jdbc\5.0.2.RELEASE\5efc255d4073cfa639ecf8e92f162528519f9dd3\spring-jdbc-5.0.2.RELEASE.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.springframework\spring-tx\5.0.2.RELEASE\38ef30ad6e34b5004c8955685b6a7ea753717b7d\spring-tx-5.0.2.RELEASE.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.springframework\spring-beans\5.0.2.RELEASE\301ee07b390bc8b5691f4206411b49beb06f7ff2\spring-beans-5.0.2.RELEASE.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.springframework\spring-test\5.0.2.RELEASE\a6fdd26c9a21958134522a5232e9f23929985f9\spring-test-5.0.2.RELEASE.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.springframework\spring-expression\5.0.2.RELEASE\246bf50b5b46379041d333b4a46a01a7aea0b788\spring-expression-5.0.2.RELEASE.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.springframework\spring-core\5.0.2.RELEASE\45b2958ab3fb022dd29f8b1c553ebf1c75a144aa\spring-core-5.0.2.RELEASE.jar, D:\DiskZ_new\Private-Repo.m2\repository\org\glassfish\javax.json\1.0.4\javax.json-1.0.4.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.apache.commons\commons-dbcp2\2.1.1\c4f4a76171671ccf293be8995a498eab7fa8ed24\commons-dbcp2-2.1.1.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.apache.derby\derby\10.14.1.0\3bcd8b1af3f8cd022d54d331e00064776be04f9c\derby-10.14.1.0.jar, D:\DiskZ_new\Private-Repo.m2\repository\com\h2database\h2\1.4.196\h2-1.4.196.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.flywaydb\flyway-core\5.0.6\e556ec2d6ac8bddbd2eb69e8d389b615bb12d4cd\flyway-core-5.0.6.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.hibernate\hibernate-core\5.2.12.Final\ea479b6692e22c9b642dd4142db670e92d106544\hibernate-core-5.2.12.Final.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.hibernate\hibernate-jpamodelgen\5.2.12.Final\7e8ab227e65bbb7842bed044fb35fb0ee06b89c0\hibernate-jpamodelgen-5.2.12.Final.jar, D:\DiskZ_new\Private-Repo.m2\repository\org\hibernate\validator\hibernate-validator\6.0.5.Final\hibernate-validator-6.0.5.Final.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jdk8\2.9.2\9b0b7c623262e29c73e8f6a78f6150372d2066f8\jackson-datatype-jdk8-2.9.2.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.springframework\spring-jcl\5.0.2.RELEASE\212a0bdd54e026641cf527aeb8e578f86e402bf1\spring-jcl-5.0.2.RELEASE.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\io.reactivex.rxjava2\rxjava\2.1.7\8c6d3f76a0b8ed49e9d49a5af9c80c5fc2091677\rxjava-2.1.7.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\com.fasterxml.jackson.module\jackson-module-parameter-names\2.9.2\be78ca220839b2c53ebd33fd4d580b5a0cacdd5a\jackson-module-parameter-names-2.9.2.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\com.fasterxml.jackson.datatype\jackson-datatype-jsr310\2.9.2\e1653d338703d8233cc1ac18c6722510bdaceb4f\jackson-datatype-jsr310-2.9.2.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-databind\2.9.2\1d8d8cb7cf26920ba57fb61fa56da88cc123b21f\jackson-databind-2.9.2.jar, D:\DiskZ_new\Private-Repo.m2\repository\javax\validation\validation-api\2.0.0.Final\validation-api-2.0.0.Final.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\com.google.guava\guava\23.6-jre\c0b638df79e7b2e1ed98f8d68ac62538a715ab1d\guava-23.6-jre.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.aspectj\aspectjrt\1.8.13\bfc5a877fd80648e5467239d370735654aaf7a92\aspectjrt-1.8.13.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.apache.commons\commons-pool2\2.4.3\e7ab2a5143cb4e0b21d8ca81c265095e4567dd22\commons-pool2-2.4.3.jar, D:\DiskZ_new\Private-Repo.m2\repository\org\hibernate\common\hibernate-commons-annotations\5.0.1.Final\hibernate-commons-annotations-5.0.1.Final.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.jboss.logging\jboss-logging\3.3.1.Final\c46217ab74b532568c0ed31dc599db3048bd1b67\jboss-logging-3.3.1.Final.jar, D:\DiskZ_new\Private-Repo.m2\repository\org\hibernate\javax\persistence\hibernate-jpa-2.1-api\1.0.0.Final\hibernate-jpa-2.1-api-1.0.0.Final.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.javassist\javassist\3.22.0-CR2\44eaf0990dea92f4bca4b9931b2239c0e8756ee7\javassist-3.22.0-CR2.jar, D:\DiskZ_new\Private-Repo.m2\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar, D:\DiskZ_new\Private-Repo.m2\repository\org\jboss\spec\javax\transaction\jboss-transaction-api_1.2_spec\1.0.1.Final\jboss-transaction-api_1.2_spec-1.0.1.Final.jar, D:\DiskZ_new\Private-Repo.m2\repository\org\jboss\jandex\2.0.3.Final\jandex-2.0.3.Final.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\com.fasterxml\classmate\1.3.4\3d5f48f10bbe4eb7bd862f10c0583be2e0053c6\classmate-1.3.4.jar, D:\DiskZ_new\Private-Repo.m2\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-core\2.9.2\aed20e50152a2f19adc1995c8d8f307c7efa414d\jackson-core-2.9.2.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.reactivestreams\reactive-streams\1.0.1\1b1c911686eb40179219466e6a59b634b9d7a748\reactive-streams-1.0.1.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\com.fasterxml.jackson.core\jackson-annotations\2.9.0\7c10d545325e3a6e72e06381afe469fd40eb701\jackson-annotations-2.9.0.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\com.google.code.findbugs\jsr305\1.3.9\40719ea6961c0cb6afaeb6a921eaa1f6afd4cfdf\jsr305-1.3.9.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.checkerframework\checker-compat-qual\2.0.0\fc89b03860d11d6213d0154a62bcd1c2f69b9efa\checker-compat-qual-2.0.0.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\com.google.errorprone\error_prone_annotations\2.1.3\39b109f2cd352b2d71b52a3b5a1a9850e1dc304b\error_prone_annotations-2.1.3.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\com.google.j2objc\j2objc-annotations\1.1\976d8d30bebc251db406f2bdb3eb01962b5685b3\j2objc-annotations-1.1.jar, D:\DiskZ_new\Private-gradle-home\caches\modules-2\files-2.1\org.codehaus.mojo\animal-sniffer-annotations\1.14\775b7e22fb10026eed3f86e8dc556dfafe35f2d5\animal-sniffer-annotations-1.14.jar]


after filtering, path is: [D:\DiskZ_new\Private-Project-Folder\gmoney\gmoney-master\gmoney-jpa\build\resources\main, D:\DiskZ_new\Private-Project-Folder\gmoney\gmoney-master\gmoney-jpa\build\classes\java\main]

jkubrynski commented 6 years ago

Does it mean you keep entities in separate jar? Generally, this plugin is intended to be run from the project containing the entities definition. We can add a switch to include whole classpath, but maybe there is something else we could do to solve it?

gpaglia commented 6 years ago

No, my entities are all in the main sourceset. But I have entities (like the one below) that have business logic methods returning types defined in external jars, and it is on these types that Hibernate complains (as with IMultiBalance below). Note that I have set AccessType to field, so that those emthods should be irrelevant for mapping, and in fact I don’t understand why Hibernate shuld need to instantiate those tpes rusing schema generation…

Here’s the scenario that shows the problem:

@Entity @DiscriminatorValue("CONTAINER") @Access(AccessType.FIELD) public class ContainerAccount extends Account{

@OneToMany(mappedBy = "parentAccount", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Account> accounts = new ArrayList<>();

protected ContainerAccount() {
    super();
}

public ContainerAccount(
        UUID id,
        String name,
        AccountType accountType,
        Currency currency) {
    super(id, name, accountType, currency);
}

public List<Account> getAccounts() {
    return accounts;
}

public void addAccount(Account account) {
    if (! accounts.contains(account)) {
        account.setParentAccountLocal(this);
        accounts.add(account);
    } else {
        throw new IllegalArgumentException("Duplicate account " + account.getName() + "in parent");
    }
}

public void removeAccount(Account account) {
    if (accounts.contains(account)) {
        accounts.remove(account);
        account.setParentAccountLocal(null);
    } else {
        throw new IllegalArgumentException("Account " + account.getName() + " not found in parent");
    }
}

// Business logic

public IMultiBalance getMultiBalance() {
    IMultiBalance mb = new MultiBalance();

    for (Account a : accounts) {
        if (a.getAccountType().isContainer()) {
            ContainerAccount ca = (ContainerAccount) a;
            mb = mb.add(ca.getMultiBalance());
        } else {
            mb = mb.add(a.getCurrency().getId(), a.getBalance());
        }
    }

    return mb;
}

} Da: Jakub Kubryński Inviato: domenica 28 gennaio 2018 21:39 A: Devskiller/jpa2ddl Cc: Gian Enrico Paglia; Mention Oggetto: Re: [Devskiller/jpa2ddl] Problem with gradle plugin 0.9.9 underwindows10 (#14)

Does it mean you keep entities in separate jar? Generally, this plugin is intended to be run from the project containing the entities definition. We can add a switch to include whole classpath, but maybe there is something else we could do to solve it? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

jkubrynski commented 6 years ago

Yes! You're totally right. I forgot about external libraries like even joda that are required to process the mapping. I'll create a fix asap

gpaglia commented 6 years ago

Ok thanks, a lot, g

Da: Jakub Kubryński Inviato: lunedì 29 gennaio 2018 10:31 A: Devskiller/jpa2ddl Cc: Gian Enrico Paglia; Mention Oggetto: Re: [Devskiller/jpa2ddl] Problem with gradle plugin 0.9.9 underwindows10 (#14)

Yes! You're totally right. I forgot about external libraries like even joda that are required to process the mapping. I'll create a fix asap — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

jkubrynski commented 6 years ago

Released in 0.9.11

gpaglia commented 6 years ago

I’ll test it right away…

Da: Jakub Kubryński Inviato: lunedì 29 gennaio 2018 11:06 A: Devskiller/jpa2ddl Cc: Gian Enrico Paglia; Mention Oggetto: Re: [Devskiller/jpa2ddl] Problem with gradle plugin 0.9.9 underwindows10 (#14)

Released in 0.9.11 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

gpaglia commented 6 years ago

I confirm it now works OK in my setup.

Many thanks, G

Da: Jakub Kubryński Inviato: lunedì 29 gennaio 2018 11:06 A: Devskiller/jpa2ddl Cc: Gian Enrico Paglia; Mention Oggetto: Re: [Devskiller/jpa2ddl] Problem with gradle plugin 0.9.9 underwindows10 (#14)

Released in 0.9.11 — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

jkubrynski commented 6 years ago

Great!