OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Combines classes from javac.custom.classpath property and ${out.dir}/classes | 6 * Combines classes from javac.custom.classpath property and ${out.dir}/classes |
7 * into a single jar file ${ant.project.name}.jar and places the file in | 7 * into a single jar file ${ant.project.name}.jar and places the file in |
8 * ${lib.java.dir}. | 8 * ${lib.java.dir}. |
9 */ | 9 */ |
10 | 10 |
11 importClass(java.io.File); | 11 importClass(java.io.File); |
12 importClass(org.apache.tools.ant.types.Reference); | 12 importClass(org.apache.tools.ant.types.Reference); |
13 importClass(org.apache.tools.ant.types.FileSet); | 13 importClass(org.apache.tools.ant.types.FileSet); |
14 importClass(org.apache.tools.ant.types.ZipFileSet); | 14 importClass(org.apache.tools.ant.types.ZipFileSet); |
15 importClass(org.apache.tools.ant.taskdefs.Zip); | 15 importClass(org.apache.tools.ant.taskdefs.Zip); |
16 | 16 |
17 var jarTask = project.createTask("jar"); | 17 var jarTask = project.createTask("jar"); |
18 | 18 |
19 // Do not allow duplicates in the jar, the default behavior of Jar task | 19 // Do not allow duplicates in the jar, the default behavior of Jar task |
20 // is "add" which means duplicates are allowed. | 20 // is "add" which means duplicates are allowed. |
21 // This can cause a class file to be included multiple times, setting the | 21 // This can cause a class file to be included multiple times, setting the |
22 // duplicate to "preserve" ensures that only the first definition is included. | 22 // duplicate to "preserve" ensures that only the first definition is included. |
23 | 23 |
24 var duplicate = Zip.Duplicate(); | 24 var duplicate = Zip.Duplicate(); |
25 duplicate.setValue("preserve"); | 25 duplicate.setValue("preserve"); |
26 jarTask.setDuplicate(duplicate); | 26 jarTask.setDuplicate(duplicate); |
27 | 27 |
28 var destFile = project.getProperty("ant.project.name") + ".jar"; | 28 var destPath = File(project.getProperty("TEST_JAR_PATH")); |
29 var destPath = File(project.getProperty("test.lib.java.dir") + "/" + destFile); | |
30 jarTask.setDestFile(destPath); | 29 jarTask.setDestFile(destPath); |
31 | 30 |
32 // Include all the jars in the classpath. | 31 // Include all the jars in the classpath. |
33 var javacCustomClasspath = | 32 var javacCustomClasspath = |
34 project.getReference("javac.custom.classpath").list(); | 33 project.getReference("javac.custom.classpath").list(); |
35 | 34 |
36 for (var i in javacCustomClasspath) { | 35 for (var i in javacCustomClasspath) { |
37 var fileName = javacCustomClasspath[i] | 36 var fileName = javacCustomClasspath[i] |
38 var fileExtension = fileName.split("\\.").pop(); | 37 var fileExtension = fileName.split("\\.").pop(); |
39 if(fileExtension == "jar") | 38 if(fileExtension == "jar") |
(...skipping 17 matching lines...) Expand all Loading... |
57 var excludedClasses = ["R.class", "R$*.class", "Manifest.class", | 56 var excludedClasses = ["R.class", "R$*.class", "Manifest.class", |
58 "Manifest$*.class", "BuildConfig.class"] | 57 "Manifest$*.class", "BuildConfig.class"] |
59 | 58 |
60 var exclusionString = ""; | 59 var exclusionString = ""; |
61 for (var i in excludedClasses) { | 60 for (var i in excludedClasses) { |
62 exclusionString += appPackagePath+ "/" + excludedClasses[i] + " "; | 61 exclusionString += appPackagePath+ "/" + excludedClasses[i] + " "; |
63 } | 62 } |
64 | 63 |
65 jarTask.setExcludes(exclusionString); | 64 jarTask.setExcludes(exclusionString); |
66 jarTask.perform(); | 65 jarTask.perform(); |
OLD | NEW |