Chromium Code Reviews| Index: build/android/ant/create-test-jar.js |
| diff --git a/build/android/ant/create-test-jar.js b/build/android/ant/create-test-jar.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..9582671983a24cbf83674f38908ff30d13fb2e0d |
| --- /dev/null |
| +++ b/build/android/ant/create-test-jar.js |
| @@ -0,0 +1,64 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +/** |
| + * Combines classes from javac.custom.classpath property and ${out.dir}/classes |
| + * into a single jar file ${ant.project.name}-debug.jar and places the file in |
| + * ${lib.java.dir}. |
| + */ |
| + |
| +importClass(java.io.File); |
| +importClass(org.apache.tools.ant.types.Reference); |
| +importClass(org.apache.tools.ant.types.FileSet); |
| +importClass(org.apache.tools.ant.types.ZipFileSet); |
| +importClass(org.apache.tools.ant.taskdefs.Zip); |
| + |
| +var echo = project.createTask("echo"); |
| + |
| +// Include all the jars in the classpath. |
| +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.
|
| + project.getReference("javac.custom.classpath").list(); |
|
cjhopman
2012/09/06 22:33:41
Nit: indent 4
shashi
2012/09/07 00:41:33
Done.
|
| +var jarTask = project.createTask("jar"); |
| + |
| +// Do not allow duplicates in the jar, the default behavior of Jar task |
| +// is "add" which means duplicates are allowed. |
| +// This can cause a class file to be included multiple times, setting the |
| +// 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.
|
| + |
| +var duplicate = Zip.Duplicate(); |
| +duplicate.setValue("preserve"); |
| +jarTask.setDuplicate(duplicate); |
| + |
| +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.
|
| +var destPath = File(project.getProperty("test.lib.java.dir") + "/" + destFile); |
| +jarTask.setDestFile(destPath); |
| + |
| +for (var i in javacCustomClasspath) { |
| + var zipFileSet = ZipFileSet(); |
| + zipFileSet.setIncludes("**/*.class"); |
| + zipFileSet.setSrc(File(javacCustomClasspath[i])); |
| + jarTask.addFileset(zipFileSet); |
| +} |
| + |
| +// Add the compiled classes in ${out.dir}/classes. |
| +var projectClasses = FileSet(); |
| +projectClasses.setIncludes("**/*.class"); |
| +projectClasses.setDir(File(project.getProperty("out.dir") + "/classes")); |
| +jarTask.addFileset(projectClasses); |
| + |
| +// Exclude manifest and resource classes. |
| +var appPackagePath = |
| + (project.getProperty("project.app.package")).replace('.','/'); |
|
cjhopman
2012/09/06 22:33:41
Indent 4.
shashi
2012/09/07 00:41:33
Done.
|
| +var excludedClasses = ["R.class", "R$*.class", "Manifest.class", |
| + "Manifest$*.class", "BuildConfig.class"] |
| + |
| +var exclusionString = ""; |
| +for (var i in excludedClasses) { |
| + exclusionString += appPackagePath+"/"+ excludedClasses[i] +" "; |
|
cjhopman
2012/09/06 22:33:41
Fix spacing around operators.
shashi
2012/09/07 00:41:33
Done.
|
| +} |
| + |
| +jarTask.setExcludes(exclusionString); |
| +echo.setMessage("Creating test jar: " + |
| + jarTask.getDestFile().getAbsolutePath()); |
| +jarTask.perform(); |