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

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: fix indent in base.gyp. 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
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
19 // Include all the jars in the classpath.
20 var javacCustomClasspath =
cjhopman 2012/09/06 22:33:41 Maybe move this assignment down to the loop where
shashi 2012/09/07 00:41:33 Done.
21 project.getReference("javac.custom.classpath").list();
cjhopman 2012/09/06 22:33:41 Nit: indent 4
shashi 2012/09/07 00:41:33 Done.
22 var jarTask = project.createTask("jar");
23
24 // Do not allow duplicates in the jar, the default behavior of Jar task
25 // is "add" which means duplicates are allowed.
26 // This can cause a class file to be included multiple times, setting the
27 // duplicate to "preserve" allows only the first definition is included.
cjhopman 2012/09/06 22:33:41 Nit: Fix this sentence's grammar. Maybe "[...] ens
shashi 2012/09/07 00:41:33 Done.
28
29 var duplicate = Zip.Duplicate();
30 duplicate.setValue("preserve");
31 jarTask.setDuplicate(duplicate);
32
33 var destFile = project.getProperty("ant.project.name")+"-debug.jar";
cjhopman 2012/09/06 22:33:41 Fix spacing around +
shashi 2012/09/07 00:41:33 Done.
34 var destPath = File(project.getProperty("test.lib.java.dir") + "/" + destFile);
35 jarTask.setDestFile(destPath);
36
37 for (var i in javacCustomClasspath) {
38 var zipFileSet = ZipFileSet();
39 zipFileSet.setIncludes("**/*.class");
40 zipFileSet.setSrc(File(javacCustomClasspath[i]));
41 jarTask.addFileset(zipFileSet);
42 }
43
44 // Add the compiled classes in ${out.dir}/classes.
45 var projectClasses = FileSet();
46 projectClasses.setIncludes("**/*.class");
47 projectClasses.setDir(File(project.getProperty("out.dir") + "/classes"));
48 jarTask.addFileset(projectClasses);
49
50 // Exclude manifest and resource classes.
51 var appPackagePath =
52 (project.getProperty("project.app.package")).replace('.','/');
cjhopman 2012/09/06 22:33:41 Indent 4.
shashi 2012/09/07 00:41:33 Done.
53 var excludedClasses = ["R.class", "R$*.class", "Manifest.class",
54 "Manifest$*.class", "BuildConfig.class"]
55
56 var exclusionString = "";
57 for (var i in excludedClasses) {
58 exclusionString += appPackagePath+"/"+ excludedClasses[i] +" ";
cjhopman 2012/09/06 22:33:41 Fix spacing around operators.
shashi 2012/09/07 00:41:33 Done.
59 }
60
61 jarTask.setExcludes(exclusionString);
62 echo.setMessage("Creating test jar: " +
63 jarTask.getDestFile().getAbsolutePath());
64 jarTask.perform();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698