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

unknown property 'dbName' #17

Open
Merve40 opened this issue May 29, 2018 · 5 comments
Open

unknown property 'dbName' #17

Merve40 opened this issue May 29, 2018 · 5 comments

Comments

@Merve40
Copy link

Merve40 commented May 29, 2018

The plugin does not seem to recognize the dbName property. It also asks for username and password, even though I specified it in the database task.
The gradle version I'm using is 4.3.1.
This is my build.gradle:

plugins {
      id "org.hibernate.gradle.tools" version "1.2.4"
}
apply plugin: "hibernatetools-gradle-plugin"

apply plugin: 'java'

sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

if (!hasProperty('mainClass')) {
    ext.mainClass = 'gradle.hibernate.Test'
}

dependencies {
    repositories {
        mavenLocal()
        mavenCentral()
    }
    
    compile 'org.hibernate:hibernate-entitymanager:4.3.7.Final'
    compile 'org.hibernate:hibernate-core:4.3.7.Final'
    compile 'mysql:mysql-connector-java:5.1.34'
    compile 'org.apache.commons:commons-dbcp2:2.0.1'
    testCompile group: 'junit', name: 'junit', version: '4.10'
}

task packageJavadoc(type: Jar, dependsOn: 'javadoc') {
    from javadoc.destinationDir
    classifier = 'javadoc'
}

task packageSources(type: Jar) {
    from sourceSets.main.allSource
    classifier = 'sources'
}

artifacts {
    archives jar
    archives packageJavadoc
    archives packageSources
}

jar {
    manifest.attributes provider: 'someone'
    baseName = 'myProject'
    version = '0.1.0-SNAPSHOT'
}

import org.hibernate.gradle.tools.*

database{
    basePackage = "gradle.hibernate.entities"
    url         = "jdbc:mysql://0.0.0.0"
    port        = 3308
    dbName      = "mydb"
    user        = "myuser"
    password    = "mypassword"    
}
@molexx
Copy link
Contributor

molexx commented May 30, 2018

Those things have been fixed but not released yet. In the meantime you can use a build from jitpack which has been working fine for me.

The below is including my fix for dbname from PR16:

buildscript {
    repositories {
        ...
        maven { url 'https://www.jitpack.io' }
        ...
    }
    dependencies {
        ....
        classpath 'com.github.molexx:hibernatetools-gradle-plugin:dbname_fix-SNAPSHOT'	
    }
}

@Merve40
Copy link
Author

Merve40 commented May 30, 2018

The dbName error is fixed now, but it still does not generate any entities.

this it the output I get when I run ./gradlew --rerun-tasks clean hbm2java:

> Task :hbm2java 
[ant:hibernatetool] [Task worker for ':'] INFO org.hibernate.cfg.reveng.OverrideRepository - Override file: /home/merve/NetBeansProjects/test/build/generated/src/resources/hibernate.reveng.xml
HHH10001002: Using Hibernate built-in connection pool (not for production use!)
[ant:hibernatetool] [Task worker for ':'] WARN org.hibernate.tool.hbm2x.TemplateHelper - template path/home/merve/NetBeansProjects/test/templates either does not exist or is not a directory

@molexx
Copy link
Contributor

molexx commented May 30, 2018

I get that too, it's just a warning and doesn't fail the build.

Try passing --info, hopefully something will point to why it's not finding the tables you want to generate from.

@goemans
Copy link

goemans commented May 30, 2019

I think it's worth noting that the hbm2java sources will be generated in /build/generated/src/java, not in /src/main/java. Since /build is on .gitignore by default, these will be hidden from a git status.

@applitect
Copy link

Could we please get a release of the plug-in to fix this issue?

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

No branches or pull requests

4 participants