简体   繁体   English

JHipster-在build.gradle中包含其他模块/插件的位置

[英]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. 我已经基于jhipster创建了一个简单的应用程序,并且不得不添加一些库来build.gradle来开发我想要的东西。 That worked correctly. 那工作正常。 Then I had to regenerate my app since I wanted to add/remove features of jhipster itself. 然后我不得不重新生成我的应用程序,因为我想添加/删除jhipster本身的功能。 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? 因为我的build.gradle已被修改,而jhipster希望从其源中重新生成它,所以我想知道是否存在可以放置我的东西的地方,以便每当我需要再次重新生成它时,它就会在那里?

In generated files for jhipster one can spot lines like: 在生成的jhipster文件中,可以发现以下行:

//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. 因此,假设我理解正确,那么jhipster会具有其他修改“注册表”,应将其应用于文件的原始模板。 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)? 但是,它在哪里或如何使用,让jhipster知道尽管从源代码进行了修改,但仍然可以保留某些东西(我在diff视图中)?

Let's say I need additional plugin for javacc which would be: 假设我需要javacc的其他插件,具体如下:

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

and additional section of build.gradle like this: 以及build.gradle的其他部分,如下所示:

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? 放在哪里,每当我不得不重新生成代码时,它就会存在并且不会被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. 在大多数情况下,效果很好的是,您创建了一个自己的gradle脚本文件(例如custom.gradle ),然后将该文件应用到主build.gradle文件中(已经有一些行apply from ...行。

With that you can quite easily manage your custom settings even in case jhipster wants to overwrite build.gradle . 这样一来,即使jhipster要覆盖build.gradle ,您也可以轻松管理自定义设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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