Problem description
Intellij idea development tools are often used to manage project dependencies using tools such as Ant, Maven, groovy, and Gradle when developing Java projects. I used the newer gradle as a management tool in my project. However, when you run the build task for build.gradle, you typically need to set multiple directories to the source code file directory. Otherwise, once the build is finished, the source code in some directories will be ignored and not considered source.
Goal
//# build.gradle #Buildscript {repositories {maven {URL"http://repo.maven.apache.org/maven2/"} mavencentral ()} dependencies {Classpath Group:' Co.tomlee.gradle.plugins ', Name:' Gradle-thrift-plugin ',version:' 0.0.6 'Classpath"Org.springframework.boot:spring-boot-gradle-plugin:1.1.10.release")}}apply plugin:' Java 'Apply plugin:' idea 'Apply plugin:' Thrift 'Apply plugin:' Spring-boot 'Apply plugin:' War 'Sourcecompatibility =1.7version=' 1.0 'repositories {mavencentral ()}dependencies {compile' org.apache.thrift:libthrift:0.9.2 'Compile' Org.springframework:spring-orm:4.1.4.release 'Compile' Org.springframework.boot:spring-boot-starter-web:1.2.1.release ') Compile (' Org.springframework.boot:spring-boot-starter-data-jpa:1.2.2.release ')//compile (' org.springframework.boot:spring-boot-starter-actuator:1.2.2.release ')Compile' Org.springframework:spring-jdbc:4.1.5.release ')//compile (' com.h2database:h2:1.4.185 ') //MySQLCompile' mysql:mysql-connector-java:5.1.34 ')//HibernateCompile' org.hibernate:hibernate-entitymanager:4.3.8.final ') Compile (' Org.projectreactor.spring:reactor-spring-context:1.1.3.release ') Compile (' Org.springframework:spring-web:4.1.5.release ') Compile (' Org.springframework.amqp:spring-rabbit:1.4.2.release ') Compile (' Org.springframework.amqp:spring-amqp:1.4.2.release ') Compile group:' Org.springframework.data ', Name:' Spring-data-mongodb ',version:' 1.6.1.RELEASE 'Compile"Org.springframework.data:spring-data-rest-webmvc:2.2.1.release"Compile"com.fasterxml.jackson.core:jackson-databind:2.5.0") Compile ("com.fasterxml.jackson.core:jackson-annotations:2.5.0") Compile ("com.fasterxml.jackson.core:jackson-core:2.5.0")//compile group: ' Org.hibernate ', Name: ' Hibernate-core ', version: ' 4.3.7.Final 'Compile' Org.springframework:spring-test:4.1.5.release ') Testcompile Group:' JUnit ', Name:' JUnit ',version:' 4.11 '}generatethriftsource { // //The output directory (optional) //Outfile(' Src/main/thrift-java ') verbosefalseDebugfalseStricttrue // //Modify The Include path (optional) // //path file (' Vendor/thrift ') // //Set The thrift executable (optional) //Executable' C:\\Program Files (x86) \\Java\\jdk1.7.0_40\\bin\\thrift.exe 'Generators { // //--gen Java:hashcode,beans //java { // //Options passed to the ' Java ' generator //Option' Hashcode 'Option' Beans '} }}//Here demonstrates what to add multiple srcdirs into ProjectSourcesets {main {java {srcdirs = [' Src/main/java ',' Src/main/thrift-java ']} resources {srcdirs = [' src/main/resources ']}} Test {java {srcdirs = [' Src/test/java ',' Src/test/thrift ']} resources {srcdirs = [' src/test/resources ']}}}jar {//Set the main class entry for the executable jarManifest {Attributes' Main-class ':' Calculator. Calculatorclient ',' Implementation-title ':' Gradle quickStart '}// This'll add all the dependent jars to the Generated-jar package from{configurations.compile.collect {it. Isdirectory ()?it: Ziptree (it) } }}
Intellij idea Gradle set up a multi-source file directory