修訂 | d60ebce90702c27bf559f0fc86d455fd798e5f7c (tree) |
---|---|
時間 | 2015-11-17 06:18:44 |
作者 | MirrgieRiana |
Commiter | MirrgieRiana |
mirrg.struct.hydrogen: update: template
@@ -2,88 +2,142 @@ | ||
2 | 2 | apply plugin: 'eclipse' |
3 | 3 | apply plugin: 'maven' |
4 | 4 | |
5 | -/////////////////////////////////// | |
5 | +////////////////////////////////////////////////////////////////////// | |
6 | 6 | |
7 | +// ★グループId | |
7 | 8 | project.group = 'mirrg' |
9 | + | |
10 | +// ★成果物のID | |
8 | 11 | project.archivesBaseName = 'mirrg.struct.hydrogen' |
9 | 12 | |
10 | -version = '1.0' | |
11 | - | |
12 | -dependencies { | |
13 | - compile group: 'commons-collections', name: 'commons-collections', version: '3.2' | |
14 | - testCompile group: 'junit', name: 'junit', version: '4.+' | |
15 | - // compile group: 'mirrg', name: 'mirrg-struct-hydrogen', version: '1.0' | |
16 | -} | |
17 | - | |
18 | -/////////////////////////////////// | |
19 | - | |
20 | -sourceCompatibility = 1.8 | |
21 | -targetCompatibility = 1.8 | |
22 | - | |
23 | -tasks.withType(AbstractCompile)*.options*.encoding = tasks.withType(GroovyCompile)*.groovyOptions*.encoding = 'UTF-8' | |
24 | - | |
25 | -jar { | |
26 | - manifest { | |
27 | - //attributes 'Main-Class' : 'Main' | |
28 | - attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version | |
29 | - } | |
30 | -} | |
13 | +// ★成果物のバージョン | |
14 | +def superversion = '1.0' // 破壊的なバージョン変更 | |
15 | +def subversion = '0' // 破壊的でないバージョン変更 | |
31 | 16 | |
32 | -task sourcesJar(type: Jar, dependsOn:classes) { | |
33 | - classifier = 'sources' | |
34 | - from sourceSets.main.allSource | |
35 | -} | |
36 | - | |
37 | -task javadocJar(type: Jar, dependsOn:javadoc) { | |
38 | - classifier = 'javadoc' | |
39 | - from javadoc.destinationDir | |
40 | -} | |
41 | - | |
42 | -javadoc { | |
43 | - options.charSet = 'UTF-8' | |
44 | - options.encoding = 'UTF-8' | |
45 | -} | |
17 | +// ★依存関係 | |
18 | +dependencies { | |
46 | 19 | |
47 | -artifacts { | |
48 | - archives sourcesJar | |
49 | - archives javadocJar | |
50 | -} | |
20 | + testCompile group: 'junit', name: 'junit', version: '4.+' | |
51 | 21 | |
52 | -repositories { | |
53 | - mavenCentral() | |
54 | - maven { | |
55 | - url '../../maven' | |
56 | - } | |
57 | - | |
58 | - // ★mirrgリポジトリのデフォルトURL | |
59 | - //maven { | |
60 | - // url 'http://hg.pf.osdn.jp/view/t/ta/tacticsrealize/mirrg.struct.hydrogen/raw-file/tip/maven' | |
61 | - //} | |
22 | + //compile group: 'commons-collections', name: 'commons-collections', version: '3.2' | |
23 | + //compile group: 'mirrg', name: 'mirrg.struct.hydrogen-1.0', version: '+' | |
62 | 24 | |
63 | 25 | } |
64 | 26 | |
65 | -test { | |
66 | - systemProperties 'property': 'value' | |
27 | +// ★追加のリポジトリURL | |
28 | +def mavenRepositories = [ | |
29 | + | |
30 | + // ★mirrgリポジトリのデフォルトURL | |
31 | + //'http://hg.pf.osdn.jp/view/t/ta/tacticsrealize/mirrg.struct.hydrogen/raw-file/tip/maven', | |
32 | + | |
33 | +] | |
34 | + | |
35 | +// ★実行可能Jar | |
36 | +def mainClass = null | |
37 | + | |
38 | +def outputLocation = | |
39 | + | |
40 | + // ★'../../repos'にフォルダ出力する場合 | |
41 | + 'maven' | |
42 | + | |
43 | + // ★'../../maven'にMavenプロジェクトとして出力する場合 | |
44 | + //'dir' | |
45 | + | |
46 | +// ★まとまったJarとして出力する | |
47 | +def allInOne = false | |
48 | + | |
49 | +////////////////////////////////////////////////////////////////////// | |
50 | + | |
51 | +version = superversion + "." + subversion | |
52 | + | |
53 | +// Javaコンパイル設定 | |
54 | + | |
55 | + // ソースのJava準拠指定 | |
56 | + sourceCompatibility = 1.8 | |
57 | + targetCompatibility = 1.8 | |
58 | + | |
59 | + // ソースのエンコーディング指定 | |
60 | + tasks.withType(AbstractCompile)*.options*.encoding = tasks.withType(GroovyCompile)*.groovyOptions*.encoding = 'UTF-8' | |
61 | + | |
62 | +// Meta-Info | |
63 | +jar { | |
64 | + manifest { | |
65 | + | |
66 | + // Mainクラス指定 | |
67 | + if (mainClass != null) attributes 'Main-Class' : mainClass | |
68 | + | |
69 | + attributes 'Implementation-Title': 'Gradle Quickstart', 'Implementation-Version': version | |
70 | + | |
71 | + } | |
72 | +}; | |
73 | + | |
74 | +// ソースとJavadocを成果物に含める | |
75 | + | |
76 | + task sourcesJar(type: Jar, dependsOn:classes) { | |
77 | + classifier = 'sources' | |
78 | + from sourceSets.main.allSource | |
79 | + } | |
80 | + | |
81 | + task javadocJar(type: Jar, dependsOn:javadoc) { | |
82 | + classifier = 'javadoc' | |
83 | + from javadoc.destinationDir | |
84 | + } | |
85 | + | |
86 | + javadoc { | |
87 | + options.charSet = 'UTF-8' | |
88 | + options.encoding = 'UTF-8' | |
89 | + } | |
90 | + | |
91 | + artifacts { | |
92 | + archives sourcesJar | |
93 | + archives javadocJar | |
94 | + } | |
95 | + | |
96 | +// 追加のMavenリポジトリURL設定 | |
97 | +repositories { | |
98 | + mavenCentral() | |
99 | + maven { | |
100 | + url '../../maven' | |
101 | + } | |
102 | + | |
103 | + mavenRepositories.each { | |
104 | + def a = it | |
105 | + maven { | |
106 | + url a | |
107 | + } | |
108 | + } | |
109 | + | |
67 | 110 | } |
68 | 111 | |
69 | -uploadArchives { | |
70 | - repositories { | |
112 | +/* | |
113 | +test { | |
114 | + systemProperties 'property': 'value' | |
115 | +} | |
116 | +*/ | |
71 | 117 | |
72 | - // ★まとまったJarとしてフォルダ出力する場合 | |
73 | - //flatDir { | |
74 | - // dirs 'repos' | |
75 | - //} | |
118 | +// 成果物の出力先 | |
119 | +uploadArchives { | |
120 | + repositories { | |
76 | 121 | |
77 | - // ★mavenプロジェクトとして出力する場合 | |
78 | - mavenDeployer { | |
79 | - pom.artifactId = project.archivesBaseName.replace('.', '-') | |
80 | - repository(url: 'file://localhost/' + file('../../maven').getAbsolutePath()) | |
81 | - } | |
122 | + if (outputLocation == 'dir') { | |
123 | + flatDir { | |
124 | + dirs '../../repos' | |
125 | + } | |
126 | + } | |
82 | 127 | |
83 | - } | |
128 | + if (outputLocation == 'maven') { | |
129 | + mavenDeployer { | |
130 | + pom.artifactId = project.archivesBaseName + "-" + superversion | |
131 | + repository(url: 'file://localhost/' + file('../../maven').getAbsolutePath()) | |
132 | + } | |
133 | + } | |
134 | + | |
135 | + } | |
84 | 136 | } |
85 | 137 | |
86 | -// ★まとまったJarとしてフォルダ出力する場合 | |
87 | -//jar { | |
88 | -// from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } | |
89 | -//} | |
138 | +// 依存Jarを同封 | |
139 | +if (allInOne) { | |
140 | + jar { | |
141 | + from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } | |
142 | + } | |
143 | +} |
@@ -0,0 +1,6 @@ | ||
1 | +package mirrg; | |
2 | + | |
3 | +public class Dummy | |
4 | +{ | |
5 | + | |
6 | +} |
@@ -1,1 +0,0 @@ | ||
1 | -<some-element/> |
@@ -0,0 +1,6 @@ | ||
1 | +package mirrg; | |
2 | + | |
3 | +public class DummyTest | |
4 | +{ | |
5 | + | |
6 | +} |
@@ -1,6 +0,0 @@ | ||
1 | -package org.gradle; | |
2 | - | |
3 | -public class PersonTest | |
4 | -{ | |
5 | - | |
6 | -} |
@@ -1,1 +0,0 @@ | ||
1 | -<some-resource/> |