Gradle Goodness: Set Java Compiler Encoding

If we want to set an explicit encoding for the Java compiler in Gradle we can use the options.encoding property. For example we could add the following line to our Gradle build file to change the encoding for the compileJava task:

view sourceprint?

0.apply plugin: ‘java‘

1.

2.compileJava.options.encoding = ‘UTF-8‘

To set the encoding property on all compile tasks in our project we can use the withType() method on the TaskContainer to find all tasks of type Compile. Then we can set the encoding in the configuration closure:

view sourceprint?

0.apply plugin: ‘java‘

1.

2.tasks.withType(Compile) {

3.options.encoding = ‘UTF-8‘

4.}

时间: 2024-10-19 02:11:21

Gradle Goodness: Set Java Compiler Encoding的相关文章

Gradle Goodness: Set Java Compiler Encoding--转载

原文地址:http://java.dzone.com/articles/gradle-goodness-set-java If we want to set an explicit encoding for the Java compiler in Gradle we can use the options.encoding property. For example we could add the following line to our Gradle build file to chan

Gradle Goodness: Running Java Applications from External Dependency

With Gradle we can execute Java applications using the JavaExec task or the javaexec() method. If we want to run Java code from an external dependency we must first pull in the dependency with the Java application code. The best way to do this is to

Gradle Goodness: Init Script for Adding Extra Plugins to Existing Projects

Gradle Goodness: Init Script for Adding Extra Plugins to Existing Projects Gradle is very flexible. One of the ways to alter the build configuration is with initialization or init scripts. These are like other Gradle scripts but are executed before t

Gradle工程错误:Gradle sync failed: Java home is different

Gradle sync failed: Java home is different (1)错误描述 Gradle sync failed: The newly created daemon process has a different context than expected. It won't be possible to reconnect to this daemon. Context mismatch: Java home is different. Wanted: Default

maven -- 问题解决(三)Java compiler level does not match the version of the installed Java project facet

问题: Java compiler level does not match the version of the installed Java project facet 解决方法如下: properties->Java Compiler,修改JDK版本,然后Apply

Error:java: Compilation failed: internal java compiler error

1.新建maven项目时,jdk用的是1.8,但是编译代码提示失败 IDE要设置几个地方 1.点击项目 选择 project structure 2.设置project的 project sdk 和 project language level 3.设置modules的jdk版本,选择8 4.选择setting,设置java compiler 选择jdk1.8

eclipse build path与java Compiler

在eclipse中开发的项目有个java build path中可以配置的jdk,还有个java compiler中可以配置compiler level,这两个是有区别的,java compiler level的JDK版本是你在eclipse中开发代码,给你提示报错的和将java文件编译成class文件需要用到的版本:build path中版本号的作用是指明你将来运行的环境. 如果build path的版本低于compiler版本,则会报 Unsupported major.minor vers

Java compiler level does not match解决方法

从别的地方导入一个项目的时候,经常会遇到eclipse/Myeclipse报Description  Resource Path Location Type Java compiler level does not match the version of the installed Java project facet.出现这个问题的原因是因为,eclipse/myeclipse的jdk编译版本与出现问题的项目JDK编译版本不一致所导致! 工具/原料 eclipse/MyEclipse 方法/

Intellij编译时报“java: System Java Compiler was not found in classpath” 解决办法

Intellij编译时报“java: System Java Compiler was not found in classpath” 解决方法: Project Settings > Compiler > Java Compiler changed the drop down Use compiler from Javac to Eclipse!