Revision: 3896
          http://vexi.svn.sourceforge.net/vexi/?rev=3896&view=rev
Author:   mkpg2
Date:     2010-09-10 02:25:09 +0000 (Fri, 10 Sep 2010)

Log Message:
-----------
Fixed/improved JarShrinkAssembler.

Modified Paths:
--------------
    trunk/org.vexi-build.shared/meta/upstream.revisions
    
trunk/org.vexi-build.shrink/src/main/java/org/vexi/build/shrink/JarShrinkAssembler.java
    trunk/org.vexi-core.download/meta/component-assembly.xml

Property Changed:
----------------
    trunk/org.vexi-build.jencode/
    trunk/org.vexi-build.shrink/
    trunk/org.vexi-core.devtools/
    trunk/org.vexi-core.download/
    trunk/org.vexi-core.main/
    trunk/org.vexi-core.truetype/


Property changes on: trunk/org.vexi-build.jencode
___________________________________________________________________
Modified: svn:ignore
   - .classpath

.settings

.project

build

   + .classpath

.settings

.project

build

release


Modified: trunk/org.vexi-build.shared/meta/upstream.revisions
===================================================================
--- trunk/org.vexi-build.shared/meta/upstream.revisions 2010-09-10 00:31:07 UTC 
(rev 3895)
+++ trunk/org.vexi-build.shared/meta/upstream.revisions 2010-09-10 02:25:09 UTC 
(rev 3896)
@@ -1 +1 @@
-{"https:\/\/svn.origo.ethz.ch\/ebuild":"64"}
\ No newline at end of file
+{"https:\/\/svn.origo.ethz.ch\/ebuild":"workspace"}
\ No newline at end of file


Property changes on: trunk/org.vexi-build.shrink
___________________________________________________________________
Modified: svn:ignore
   - build

.project

.settings

.classpath

lib

   + build

.project

.settings

.classpath

lib

release


Modified: 
trunk/org.vexi-build.shrink/src/main/java/org/vexi/build/shrink/JarShrinkAssembler.java
===================================================================
--- 
trunk/org.vexi-build.shrink/src/main/java/org/vexi/build/shrink/JarShrinkAssembler.java
     2010-09-10 00:31:07 UTC (rev 3895)
+++ 
trunk/org.vexi-build.shrink/src/main/java/org/vexi/build/shrink/JarShrinkAssembler.java
     2010-09-10 02:25:09 UTC (rev 3896)
@@ -6,7 +6,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.Set;
 
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.types.Path;
@@ -38,50 +37,74 @@
         }
     }
     
+    private void addToClassPath(ClassPath cp, Collection<File> in){
+        for(File f: in){
+            ClassPathEntry cpe = new ClassPathEntry(f, false);
+            
cpe.setFilter(CollectionUtil.singletonList("!META-INF/MANIFEST.MF"));
+            cp.add(cpe);
+        }
+    }
+    
     public Collection<File> assemble(IAssemblerArgument argument) throws 
BuildPluginException {
         ILogger logger = argument.getLogger();
         IPropertyMap props = argument.getPropertyMap();
         
-        Set<String> preserveSet = CollectionUtil.EMPTY_SET;
-        {
-            String preserve = props.getString("preserve");
-            if(preserve!=null){
-                preserveSet = 
CollectionUtil.newSet(((String)preserve).split(","));
-            }
+//        Set<String> preserveSet = CollectionUtil.EMPTY_SET;
+//        {
+//            String preserve = props.getString("preserve");
+//            if(preserve!=null){
+//                preserveSet = 
CollectionUtil.newSet(((String)preserve).split(","));
+//            }
+//        }
+        
+        Collection<File> shrinkJars = 
argument.getInputMap().expectArtifacts("shrink");
+        Collection<File> preservedJars = 
argument.getInputMap().getArtifacts("preserve", new HashSet());
+        Collection<File> libraryJars = 
argument.getInputMap().getArtifacts("library", new HashSet());
+        shrinkJars.removeAll(preservedJars);
+        shrinkJars.removeAll(libraryJars);
+        libraryJars.add(getJavaLib());
+        
+        logger.log("shrink:");
+        for(File f: shrinkJars){
+            logger.log("    "+f.getAbsolutePath());
         }
-        File in = argument.getInputMap().expectLoneArtifact();
         
-        Configuration conf = new Configuration();
-        File shrunkJar = new File(argument.getOutputDirectory(), "shrunk.jar");
-        Set<File> preservedJars = new HashSet();
-        {
-            ClassPath libjars = new ClassPath();
-            ClassPath injars = new ClassPath();
-            libjars.add(new ClassPathEntry(getJavaLib(), false));
-            
-            for(File f: in.listFiles()){
-                ClassPathEntry cpe = new ClassPathEntry(f, false);
-                
cpe.setFilter(CollectionUtil.singletonList("!META-INF/MANIFEST.MF"));
-                if(preserveSet.contains(f.getName())){
-                    libjars.add(cpe);
-                    preservedJars.add(f);
-                }else{
-                    injars.add(cpe);
-                }
-            }
-            
-            injars.add(new ClassPathEntry(shrunkJar, true));
-            
-            
-            conf.programJars = injars;
-            conf.libraryJars = libjars;
+        logger.log("preserve:");
+        for(File f: preservedJars){
+            logger.log("    "+f.getAbsolutePath());
         }
+
+        logger.log("library:");
+        for(File f: libraryJars){
+            logger.log("    "+f.getAbsolutePath());
+        }
+        File shrinkOutputJar = new File(argument.getOutputDirectory(), 
"shrunk.jar");
         
-        if(in.lastModified()>shrunkJar.lastModified()){
+        // REMARK as far as proguard is concerned our preserved jars are 
library jars. 
+        ClassPath programJarsPath = new ClassPath();
+        addToClassPath(programJarsPath, shrinkJars);
+        programJarsPath.add(new ClassPathEntry(shrinkOutputJar, true));
+        
+        ClassPath libraryJarsPath = new ClassPath();
+        addToClassPath(libraryJarsPath, preservedJars);
+        addToClassPath(libraryJarsPath, libraryJars);
+        
+        
+        Configuration conf = new Configuration();
+        conf.programJars = programJarsPath;
+        conf.libraryJars = libraryJarsPath;
+        
+
+        
+        //-libraryjars &lt;java.home>/${j2se_classes}
+        
+        if(FileUtil.lastModified(shrinkJars)>shrinkOutputJar.lastModified()){
             String proguard_options = props.getString("proguard_options","");
 
             // prime logger
             logger.log("Shrinking with proguard");
+            ILogger pgLogger = logger.newSubLogger("ProGuard");
+            pgLogger.prime();
             ProGuard pg = new ProGuard(conf);
             try {
                 
@@ -100,14 +123,14 @@
 
         
         if(preservedJars.size()==0) {
-            return singletonList(shrunkJar);
+            return singletonList(shrinkOutputJar);
         }
         //////////////
         // STAGE 2 combine
         
         Collection<File> path = new ArrayList(preservedJars.size()+1);
         path.addAll(preservedJars);
-        path.add(shrunkJar);
+        path.add(shrinkOutputJar);
         
         File combined = new File(argument.getOutputDirectory(),"combined.jar");
         if(FileUtil.lastModified(path)>combined.lastModified()){


Property changes on: trunk/org.vexi-core.devtools
___________________________________________________________________
Modified: svn:ignore
   - src_gen

_vexi_test

_temp_

bin

.project

.settings

.classpath

build

gen

lib

   + src_gen

_vexi_test

_temp_

bin

.project

.settings

.classpath

build

gen

lib

release



Property changes on: trunk/org.vexi-core.download
___________________________________________________________________
Modified: svn:ignore
   - build

.project

   + build

.project

release


Modified: trunk/org.vexi-core.download/meta/component-assembly.xml
===================================================================
--- trunk/org.vexi-core.download/meta/component-assembly.xml    2010-09-10 
00:31:07 UTC (rev 3895)
+++ trunk/org.vexi-core.download/meta/component-assembly.xml    2010-09-10 
02:25:09 UTC (rev 3896)
@@ -21,7 +21,12 @@
                        <else>
                                <assembler source="local" name="build.shrink">
                                        <input name="shrink" 
ref="constituents"/>
-                                       <property key="preserve" 
value="mipsapps.jar,org.ibex.nestedvm_rt.jar"/>
+                                       <input name="preserve">
+                                               <module-selection 
artifact-type="java.classes">
+                                                       <include source="local" 
name="core.truetype"/>
+                                                       <include source="local" 
name="core.devtools" confs="devtools"/>
+                                               </module-selection>
+                                       </input>
                                        <property key="proguard_options">
                                                -dontobfuscate 
                                                


Property changes on: trunk/org.vexi-core.main
___________________________________________________________________
Modified: svn:ignore
   - 
src_gen
bin

_vexi_test

_temp_

src_gen*

.classpath

.project

gen

.settings

build

lib

ebuild.configuration

   + 
src_gen
bin

_vexi_test

_temp_

src_gen*

.classpath

.project

gen

.settings

build

lib

ebuild.configuration

release



Property changes on: trunk/org.vexi-core.truetype
___________________________________________________________________
Modified: svn:ignore
   - .settings

build

.classpath

.project

ebuild.configuration

gen

lib

   + .settings

build

.classpath

.project

ebuild.configuration

gen

lib

release



This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Automate Storage Tiering Simply
Optimize IT performance and efficiency through flexible, powerful, 
automated storage tiering capabilities. View this brief to learn how
you can reduce costs and improve performance. 
http://p.sf.net/sfu/dell-sfdev2dev
_______________________________________________
Vexi-svn mailing list
Vexi-svn@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/vexi-svn

Reply via email to