Browse Source

Add target to bundle plugins in jar.

Building client:fatjar will bundle all plugins in the 'plugin'
configuration in gradle (currently IRC parser, Swing UI, two
tab completers) into a client jar.

Fixes #100
pull/163/head
Chris Smith 9 years ago
parent
commit
60c01ba6e7
1 changed files with 51 additions and 5 deletions
  1. 51
    5
      build.gradle

+ 51
- 5
build.gradle View File

@@ -11,7 +11,11 @@ apply plugin: 'pmd'
11 11
 
12 12
 configurations {
13 13
     bundle
14
-    plugin
14
+
15
+    plugin {
16
+        transitive = false
17
+    }
18
+
15 19
     compile {
16 20
         extendsFrom bundle
17 21
     }
@@ -149,14 +153,33 @@ task createVersionConfig {
149 153
         def resolvedConfiguration = compileConfiguration.resolvedConfiguration
150 154
         def resolvedArtifacts = resolvedConfiguration.resolvedArtifacts
151 155
         resolvedArtifacts.each { dp ->
152
-           def version = dp.moduleVersion.id
153
-           targetFile << " " + version.group + " " + version.name + " " + version.version + "\n"
156
+            def version = dp.moduleVersion.id
157
+            targetFile << " " + version.group + " " + version.name + " " + version.version + "\n"
154 158
         }
155 159
 
156 160
         // Copy to the build directory so it's accessible during tests
157 161
         java.nio.file.Files.copy(targetFile.toPath(),
158
-           sourceSets.main.output.classesDir.toPath().resolve('com').resolve('dmdirc').resolve('version.config'),
159
-           java.nio.file.StandardCopyOption.REPLACE_EXISTING);
162
+            sourceSets.main.output.classesDir.toPath().resolve('com').resolve('dmdirc').resolve('version.config'),
163
+            java.nio.file.StandardCopyOption.REPLACE_EXISTING);
164
+    }
165
+}
166
+
167
+task createFatVersionConfig {
168
+    inputs.file new File(buildDir, 'version.config')
169
+    outputs.file new File(buildDir, 'fat.version.config')
170
+    dependsOn createVersionConfig
171
+
172
+    doLast {
173
+        def sourceFile = new File(buildDir, 'version.config')
174
+        def targetFile = new File(buildDir, 'fat.version.config')
175
+
176
+        java.nio.file.Files.copy(sourceFile.toPath(), targetFile.toPath(),
177
+            java.nio.file.StandardCopyOption.REPLACE_EXISTING)
178
+
179
+        targetFile << "\nbundledplugins_versions:\n"
180
+        configurations.plugin.each { p ->
181
+            targetFile << " " + p.name.replaceFirst('-', '=').replaceAll('.jar$', '\n');
182
+        }
160 183
     }
161 184
 }
162 185
 
@@ -187,6 +210,29 @@ jar {
187 210
     }
188 211
 }
189 212
 
213
+task('fatjar', type: Jar) {
214
+    dependsOn createFatVersionConfig
215
+    baseName = 'fat-client'
216
+
217
+    from("$buildDir/fat.version.config") {
218
+        into 'com/dmdirc'
219
+        rename 'fat.version.config', 'version.config'
220
+    }
221
+
222
+    from { configurations.bundle.collect { it.isDirectory() ? it : zipTree(it) } } {
223
+        exclude 'META-INF/**'
224
+    }
225
+
226
+    into('plugins') {
227
+        from configurations.plugin
228
+        rename '(.*?)-.*(\\.jar)', '$1$2'
229
+    }
230
+
231
+    manifest {
232
+        attributes 'Main-Class': 'com.dmdirc.Main'
233
+    }
234
+}
235
+
190 236
 buildscript {
191 237
     repositories {
192 238
         mavenCentral()

Loading…
Cancel
Save