1+ plugins {
2+ id ' java'
3+ id ' org.jetbrains.intellij' version ' 0.3.4'
4+ }
5+
6+ // 2.1 插件配置
7+ // 这两个插件是必备
8+ apply plugin : ' idea'
9+ apply plugin : ' org.jetbrains.intellij'
10+
11+ group ' com.sjhy'
12+ version ' 1.0.0-SNAPSHOT'
13+
14+ sourceCompatibility = 1.8
15+
16+ repositories {
17+ mavenCentral()
18+ }
19+
20+ dependencies {
21+ compile group : ' com.fasterxml.jackson.core' , name : ' jackson-databind' , version : ' 2.9.6'
22+ testCompile group : ' junit' , name : ' junit' , version : ' 4.12'
23+ compileClasspath fileTree(dir : ' lib' , includes : [' *.jar' ])
24+ compileOnly " org.projectlombok:lombok:1.18.0"
25+ }
26+
27+ intellij {
28+ pluginName ' EasyCode'
29+ version ' 2018.1.5'
30+ type ' IU'
31+ // plugins ['com.intellij.database:2018.1.5']
32+ updateSinceUntilBuild false // Disables updating since-build attribute in plugin.xml
33+ }
34+ patchPluginXml {
35+ changeNotes """
36+ Add change notes here.<br>
37+ <em>most HTML tags may be used</em>"""
38+ }
39+
40+ tasks. withType(JavaCompile ) {
41+ options. encoding = " UTF-8"
42+ }
43+
44+
45+ // -----------------------------------change xml file encoding---------------------------------------------
46+ project. patchPluginXml. doLast {
47+ loopFileDirectoryChangeFileEncoding((File ) project. patchPluginXml. getDestinationDir())
48+ }
49+ /**
50+ * Traverse the folder, modifying the file format to utf-8
51+ */
52+ void loopFileDirectoryChangeFileEncoding (File xmlFileDirectory ) {
53+ // check directory
54+ if (xmlFileDirectory != null && xmlFileDirectory. isDirectory()) {
55+ File [] files = xmlFileDirectory. listFiles()
56+ // loop file
57+ for (File tempXmlFile : files) {
58+ if (tempXmlFile. isFile()) {
59+ String xmlPath = tempXmlFile. getPath()
60+ project. changeFileEncodingToUtf8(xmlPath)
61+ }
62+ }
63+ }
64+ }
65+ /**
66+ * Modifying the xml file to utf - 8
67+ */
68+ void changeFileEncodingToUtf8 (String xmlPath ) {
69+ try {
70+ // read xml file
71+ BufferedReader bfr = new BufferedReader (new FileReader (xmlPath))
72+ String line = bfr. readLine()
73+ StringBuilder sb = new StringBuilder ()
74+ while (line != null ) {
75+ sb. append(line)
76+ sb. append(" \n " )
77+ line = bfr. readLine()
78+ }
79+ bfr. close()
80+ // write xml file
81+ BufferedWriter writer = new BufferedWriter (new OutputStreamWriter (new FileOutputStream (xmlPath, false ), " UTF-8" ))
82+ writer. write(sb. toString())
83+ writer. flush()
84+ writer. close()
85+ } catch (IOException e) {
86+ System . out. println (" read err:" + e. toString())
87+ }
88+ }
0 commit comments