简体   繁体   中英

JHipster - Where place additional modules/plugins to be included in build.gradle

I've created simple app based on jhipster and I had to add some libraries to build.gradle to develop what I wanted. That worked correctly. Then I had to regenerate my app since I wanted to add/remove features of jhipster itself. Because my build.gradle was modified and jhipster wanted to regenerate it from it's source I was wondering if there is a place where I can put my stuff in so it would be there whenever I would have to regenerate it again?

In generated files for jhipster one can spot lines like:

//jhipster-needle-gradle-plugins - JHipster will add additional gradle plugins here

So assuming if I understand it correctly that jhipster have additional "registry" of modification which should be applied to original template of the file. But where it is or how to use this so jhipster would know that something although is modified from source is ok and should stay (I mean in the diff view)?

Let's say I need additional plugin for javacc which would be:

id "ca.coglinc2.javacc" version "3.0.0"

and additional section of build.gradle like this:

compileJavacc {
    arguments = [
            grammar_encoding: 'UTF-8',
            static: "false",
            debug_parser: "false",
            debug_lookahead: "false"
    ]
    inputDirectory = file('src/main/javacc')
    outputDirectory = file('src/main/generated/javacc')
}

compileJava.dependsOn processResources,compileJavacc
bootWar.dependsOn war
processResources.dependsOn cleanResources,bootBuildInfo
bootBuildInfo.mustRunAfter cleanResources

sourceSets {
    main {
        java {
            srcDirs 'src/main/java'
            srcDirs 'src/main/generated/javacc'
        }
    }

    test {
        java {
            srcDirs 'src/test/java'
        }
    }
}

Where to put it that whenever I would have to regenerate the code it would be there and not removed by jhipster?

There is basically no place where you can put your code. What works quite well in most cases is, that you create an own gradle script file (like custom.gradle ) and just apply that file in the main build.gradle file (there already some apply from ... lines.

With that you can quite easily manage your custom settings even in case jhipster wants to overwrite build.gradle .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM