Intellij idea中gradle设置多源文件目录
来源:互联网 发布:欠网络贷款不还怎么办 编辑:程序博客网 时间:2024/06/16 11:25
问题描述
Intellij idea开发工具来开发Java工程的时候,通常会使用ant、maven、groovy、gradle等工具来管理项目依赖。我在工程中使用了较新的gradle作为管理工具。但是在运行build.gradle的build任务时,通常需要将多个目录设置为源代码文件目录。否则一旦build完了以后,某些目录中的源代码会被忽视,而认为不是源代码。
比如说如下图所示:
- 该图中wsdc-api未被mark为源文件目录,因此该目录下所有java文件都未被识别为java源代码,因此这些代码文件左下角出现了红色的 “J”.
目标
- src/main/java 为默认的源文件目录
- src/main/thrift 也希望成为gradle可识别的源文件目录
src/main/thrift-java 也希望成为gradle可识别的源文件目录
解决方案
// # 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') // mysql compile('mysql:mysql-connector-java:5.1.34') // hibernate compile('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) // out file('src/main/thrift-java') verbose false debug false strict true // // 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 how 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 jar manifest { attributes 'Main-Class': 'calculator.CalculatorClient', 'Implementation-Title': 'Gradle quickStart' } // this will add all the dependent jars into the generated-jar package from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }}
1 0
- Intellij idea中gradle设置多源文件目录
- Mac 下Intellij idea 的Gradle设置
- intellij idea中刷新gradle无效
- intelliJ idea 中添加gradle java项目
- Intellij idea中创建目录叠加问题
- Intellij idea 从git中删除.idea目录
- IntelliJ IDEA如何在Gradle项目中支持Web Application
- intellij idea中gradle工程使用git进行版本控制
- Intellij IDEA中常用的设置
- IntelliJ IDEA中设置Eclipse常用快捷键
- IntelliJ IDEA 目录技巧
- IntelliJ IDEA 目录技巧
- IntelliJ IDEA 目录结构
- IntelliJ IDEA —— gradle
- RStudio中设置当前源文件目录作为工作目录
- Intellij idea 项目目录设置 与包的显示创建
- IntelliJ IDEA(Android Studio)中如何设置使得占用C盘空间尽量少(相关核心文件和目录介绍)
- Intellij IDEA 内存设置
- this指针
- html 中用 Jquery实现 <textarea /> 中的 maxlength属性
- Oracle 异常处理
- Android中Bitmap和Drawable Bitmap → byte[] byte[] → Bitmap Bitmap缩放 将Drawable转化为Bitmap 获得圆角图片
- 安装ubuntu系统的一些小问题总结
- Intellij idea中gradle设置多源文件目录
- Android特效 五种Toast详解
- 覆写ListView
- JAVA反射机制
- android 指定组件的圆角图片处理
- AnySDK项目实战教程
- mysql日志详细解析
- 热咖啡报表 (品尝ABAP的味道)
- UVA - 567 Risk(Floyd)