Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: build/android/ant/create-test-jar.js

Issue 10905138: Add test jar generation logic for ant builds. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: rebase Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « build/android/ant/common.xml ('k') | build/android/ant/sdk-targets.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 /**
6 * Combines classes from javac.custom.classpath property and ${out.dir}/classes
7 * into a single jar file ${ant.project.name}-debug.jar and places the file in
8 * ${lib.java.dir}.
9 */
10
11 importClass(java.io.File);
12 importClass(org.apache.tools.ant.types.Reference);
13 importClass(org.apache.tools.ant.types.FileSet);
14 importClass(org.apache.tools.ant.types.ZipFileSet);
15 importClass(org.apache.tools.ant.taskdefs.Zip);
16
17 var echo = project.createTask("echo");
18 var jarTask = project.createTask("jar");
19
20 // Do not allow duplicates in the jar, the default behavior of Jar task
21 // is "add" which means duplicates are allowed.
22 // This can cause a class file to be included multiple times, setting the
23 // duplicate to "preserve" ensures that only the first definition is included.
24
25 var duplicate = Zip.Duplicate();
26 duplicate.setValue("preserve");
27 jarTask.setDuplicate(duplicate);
28
29 var destFile = project.getProperty("ant.project.name") + "-debug.jar";
30 var destPath = File(project.getProperty("test.lib.java.dir") + "/" + destFile);
31 jarTask.setDestFile(destPath);
32
33 // Include all the jars in the classpath.
34 var javacCustomClasspath =
35 project.getReference("javac.custom.classpath").list();
36
37 for (var i in javacCustomClasspath) {
38 var fileName = javacCustomClasspath[i]
39 var fileExtension = fileName.split("\\.").pop();
40 if(fileExtension == "jar")
41 {
42 var zipFileSet = ZipFileSet();
43 zipFileSet.setIncludes("**/*.class");
44 zipFileSet.setSrc(File(fileName));
45 jarTask.addFileset(zipFileSet);
46 }
47 }
48
49 // Add the compiled classes in ${out.dir}/classes.
50 var projectClasses = FileSet();
51 projectClasses.setIncludes("**/*.class");
52 projectClasses.setDir(File(project.getProperty("out.dir") + "/classes"));
53 jarTask.addFileset(projectClasses);
54
55 // Exclude manifest and resource classes.
56 var appPackagePath =
57 (project.getProperty("project.app.package")).replace('.','/');
58 var excludedClasses = ["R.class", "R$*.class", "Manifest.class",
59 "Manifest$*.class", "BuildConfig.class"]
60
61 var exclusionString = "";
62 for (var i in excludedClasses) {
63 exclusionString += appPackagePath+ "/" + excludedClasses[i] + " ";
64 }
65
66 jarTask.setExcludes(exclusionString);
67 echo.setMessage("Creating test jar: " +
68 jarTask.getDestFile().getAbsolutePath());
69 echo.perform();
70 jarTask.perform();
OLDNEW
« no previous file with comments | « build/android/ant/common.xml ('k') | build/android/ant/sdk-targets.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698