Selaa lähdekoodia

Add input/output properties to createVersionConfig

This allows gradle to skip writing the config file if nothing
relevant has changed.
pull/153/head
Chris Smith 9 vuotta sitten
vanhempi
commit
28cdbee348
1 muutettua tiedostoa jossa 27 lisäystä ja 21 poistoa
  1. 27
    21
      build.gradle

+ 27
- 21
build.gradle Näytä tiedosto

@@ -130,27 +130,33 @@ task getCredentials << {
130 130
 task publishSnapshot(dependsOn: ['getCredentials', 'publishMavenJavaPublicationToSnapshotsRepository']) << {
131 131
 }
132 132
 
133
-task createVersionConfig << {
134
-    def targetFile = new File(buildDir, 'version.config')
135
-
136
-    targetFile.text = ''
137
-    targetFile << "keysections:\n identity\n version\n updater\n bundledplugins_versions\n\n"
138
-    targetFile << "identity:\n name=DMDirc version information\n globaldefault=true\n order=95000\n\n"
139
-    targetFile << "version:\n version=${version}\n\n"
140
-    targetFile << "updater:\n channel=${updaterChannel}\n\n"
141
-    targetFile << "buildenv:\n"
142
-    def compileConfiguration = project.configurations.getByName("compile")
143
-    def resolvedConfiguration = compileConfiguration.resolvedConfiguration
144
-    def resolvedArtifacts = resolvedConfiguration.resolvedArtifacts
145
-    resolvedArtifacts.each { dp ->
146
-       def version = dp.moduleVersion.id
147
-       targetFile << " " + version.group + " " + version.name + " " + version.version + "\n"
148
-    }
149
-
150
-    // Copy to the build directory so it's accessible during tests
151
-    java.nio.file.Files.copy(targetFile.toPath(),
152
-       sourceSets.main.output.classesDir.toPath().resolve('com').resolve('dmdirc').resolve('version.config'),
153
-       java.nio.file.StandardCopyOption.REPLACE_EXISTING);
133
+task createVersionConfig {
134
+    inputs.dir 'src'
135
+    inputs.dir 'res'
136
+    outputs.file new File(buildDir, 'version.config')
137
+
138
+    doLast {
139
+        def targetFile = new File(buildDir, 'version.config')
140
+
141
+        targetFile.text = ''
142
+        targetFile << "keysections:\n identity\n version\n updater\n bundledplugins_versions\n\n"
143
+        targetFile << "identity:\n name=DMDirc version information\n globaldefault=true\n order=95000\n\n"
144
+        targetFile << "version:\n version=${version}\n\n"
145
+        targetFile << "updater:\n channel=${updaterChannel}\n\n"
146
+        targetFile << "buildenv:\n"
147
+        def compileConfiguration = project.configurations.getByName("compile")
148
+        def resolvedConfiguration = compileConfiguration.resolvedConfiguration
149
+        def resolvedArtifacts = resolvedConfiguration.resolvedArtifacts
150
+        resolvedArtifacts.each { dp ->
151
+           def version = dp.moduleVersion.id
152
+           targetFile << " " + version.group + " " + version.name + " " + version.version + "\n"
153
+        }
154
+
155
+        // Copy to the build directory so it's accessible during tests
156
+        java.nio.file.Files.copy(targetFile.toPath(),
157
+           sourceSets.main.output.classesDir.toPath().resolve('com').resolve('dmdirc').resolve('version.config'),
158
+           java.nio.file.StandardCopyOption.REPLACE_EXISTING);
159
+    }
154 160
 }
155 161
 
156 162
 createVersionConfig.dependsOn classes

Loading…
Peruuta
Tallenna