I am purely from the Maven background, I haven't used the Gradle build so far.
Completed :
I am able to successfully build this project https://github.com/opendistro-for-elasticsearch/anomaly-detection using the
./gradlew build
As per the documentation in the project, It is mentioned that
./gradlew :run
command will launch a single node elastic search cluster with the two plugins installed. I tried and I am able to get both the plugins installed like belowhttp://127.0.0.1:9200/_cat/plugins?v&s=component&h=name,component,version,description
Question :
Now I am trying to understand this opensource code,
What is the purpose of these four tags in build.gradle (https://github.com/opendistro-for-elasticsearch/anomaly-detection) : buildscript, plugins, repositories, ext
when I look at the
build.gradle
, It seems that the following package is called for building,allprojects { group = 'com.amazon.opendistroforelasticsearch'
plugins.withId('java') { sourceCompatibility = targetCompatibility = "1.8" }
}
But where is the main method/trigger point for this code (https://github.com/opendistro-for-elasticsearch/anomaly-detection) ? Could someone look at this github project and let me know the starting point of the code so that I will debug and get the remaining context please!!
Any help is appreciated!
Thanks,
Harry
Regarding the Gradle questions, I guess they can be answered easily:
What is the purpose of these four tags:
buildscript
: This block allows to make settings that are applied BEFORE the rest of the build script is loaded. For example, this can be useful to add plugins to the classpath. But that usecase is outdated and the use of theplugins
block is recommended. (Documentation)plugins
: With this block you add plugins to the Gradle project.id 'java'
is typical for Java projects. The plugins are either shipped with Gradle or will be retrieved from remote repositories. This can be configured in the setting.gradle file if required. (Documentation)repositories
: In order to resolve artifacts from remote repositories (and push to them) you'll have to define these repos. A popular choice ismavenCentral()
andjcenter()
, but you can also define your own repos. For corporate use behind firewall we do that a lot. (Documentation)ext
: This is an extension to the Gradle project that allows you to define additional properties for use throughout the build script. Once defined, you can access them without theext.
prefix. (Documenation)allprojects
iterates over the root project and all subprojects and applies the closure to each project. In this case the group is set to the given string and a command is stored that is executed when Java plugin is applied to that project and sets Java input and output to version 1.8.As for the main method: I guess you'll have to search the project for a main method. Alternatively, it could be the framework that starts your application. In that case there must be some kind of hook (Overwritten class/implemented interface, Annotation?) for the Framework to start your actual application. You'll have to check that in the framework documentation. Quick start guides could be a great place to start looking.