axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hemap...@apache.org
Subject cvs commit: ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/utils AntExecuter.java
Date Thu, 02 Sep 2004 11:48:29 GMT
hemapani    2004/09/02 04:48:29

  Modified:    contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/utils/packager
                        ModulePackager.java
               contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/utils
                        AntExecuter.java
  Log:
  break the AntExecutor code to small methods
  
  Revision  Changes    Path
  1.2       +0 -1      ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/utils/packager/ModulePackager.java
  
  Index: ModulePackager.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/utils/packager/ModulePackager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ModulePackager.java	2 Sep 2004 05:45:14 -0000	1.1
  +++ ModulePackager.java	2 Sep 2004 11:48:29 -0000	1.2
  @@ -98,7 +98,6 @@
               ZipEntry entry = new ZipEntry(entryName);
   
               InputStream instream = (InputStream)entries.get(entryName);
  -            System.out.println(entry.getName());
               jarFile.putNextEntry(entry);
               int anz;
               while ((anz = instream.read(buf)) != -1) {
  
  
  
  1.12      +147 -75   ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/utils/AntExecuter.java
  
  Index: AntExecuter.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/contrib/ews/src/org/apache/geronimo/ews/ws4j2ee/utils/AntExecuter.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- AntExecuter.java	2 Sep 2004 05:45:14 -0000	1.11
  +++ AntExecuter.java	2 Sep 2004 11:48:29 -0000	1.12
  @@ -17,16 +17,21 @@
   package org.apache.geronimo.ews.ws4j2ee.utils;
   
   import java.io.File;
  +import java.io.FileInputStream;
   import java.io.IOException;
  +import java.io.InputStream;
  +import java.util.Properties;
   import java.util.Vector;
   import java.util.jar.JarOutputStream;
   
   import org.apache.geronimo.ews.ws4j2ee.context.J2EEWebServiceContext;
  +import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationConstants;
   import org.apache.geronimo.ews.ws4j2ee.toWs.GenerationFault;
   import org.apache.geronimo.ews.ws4j2ee.utils.packager.ModulePackager;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.taskdefs.Ant;
   import org.apache.tools.ant.taskdefs.Javac;
  +import org.apache.tools.ant.types.FileSet;
   import org.apache.tools.ant.types.Path;
   
   /**
  @@ -68,101 +73,168 @@
   //			"directory in the conf/ws4j2ee.propertites Build fill ignore the faliure");
           }
       }
  +    
  +    
  +    
       public void execute()throws GenerationFault {
           try{
               Class.forName("com.sun.tools.javac.Main");
               File outDir = new File(wscontext.getMiscInfo().getOutPutPath());
               File dest = new File(outDir,"build/classes");
  -            
  -            Project project = new Project();
  -            project.init();
  -            project.setCoreLoader(Thread.currentThread().getContextClassLoader());
  -                
  -                
  -            Javac comp = new Javac();
  -            comp.setProject(project);
  -            
  -            dest.mkdirs();
  -            comp.setDestdir(dest);
  -                
  -            Path path = new Path(project);
  -            path.setLocation(outDir);
  -            comp.setSrcdir(path);
  +            compile(outDir,dest);
  +            createModule(outDir,dest);
  +        }catch(IOException e){
  +            throw GenerationFault.createGenerationFault(e);
  +        }catch(ClassNotFoundException e){
  +            System.out.println("Ant file will not be run programatcally as the " +
  +                "$JAVA_HOME/lib/tool.jar is not in the class path. To run the ant " +
  +                "prgramatically add that jar to classpath");
  +//NOW as the code is used by Geronimo we can not afford to let the build
  +//failure tests beside if you use maven it works fine. it will find your maven 
  +//repository itself :) 
  +//        }catch(BuildException e){
  +//          System.out.println(e.getMessage() +
  +//          "if it is a compile error you may not have set the maven reposiroty " +
  +//          "directory in the conf/ws4j2ee.propertites Build fill ignore the faliure");
  +        }
  +    }
   
  -                        
  -            comp.init();
  -            comp.execute();
  -        
  -            String jarName = wscontext.getWSDLContext().getTargetPortType().getName().toLowerCase();
  -            int index = jarName.lastIndexOf(".");
  -            if(index>0){
  -                jarName = jarName.substring(index+1);
  -            } 
  +    private void createModule(File outDir,File dest)throws IOException{
  +        String jarName = wscontext.getWSDLContext().getTargetPortType().getName().toLowerCase();
  +        int index = jarName.lastIndexOf(".");
  +        if(index>0){
  +            jarName = jarName.substring(index+1);
  +        } 
   
           
  -            ModulePackager module = new ModulePackager(new File(outDir,jarName+"-ewsImpl.jar"));
  -            module.addClassFiles(dest);
  +        ModulePackager module = new ModulePackager(new File(outDir,jarName+"-ewsImpl.jar"));
  +        module.addClassFiles(dest);
               
  -            Vector classpathelements = wscontext.getMiscInfo().getClasspathElements();
  -            if(classpathelements != null){
  -                for(int i = 0;i<classpathelements.size();i++){
  -                    module.addJarFile((File)classpathelements.get(i));               
  -                }
  +        Vector classpathelements = wscontext.getMiscInfo().getClasspathElements();
  +        if(classpathelements != null){
  +            for(int i = 0;i<classpathelements.size();i++){
  +                module.addJarFile((File)classpathelements.get(i));               
               }
  +        }
   
  -            File dir = outDir;
  -            File[] files = dir.listFiles();
  -            if(files != null){
  -                for(int i = 0;i<files.length;i++){
  -                    String file = files[i].getName();
  -                    if(files[i].isFile() && 
  -                        !(file.endsWith(".jar")||
  -                            file.endsWith(".zip")||
  -                            file.endsWith(".war")||
  -                            file.endsWith(".ear")||
  -                            file.endsWith(".java"))
  -                        ){
  -                            module.addFileToJar(file,files[i]);
  -                    }
  -                        
  +        File dir = outDir;
  +        File[] files = dir.listFiles();
  +        if(files != null){
  +            for(int i = 0;i<files.length;i++){
  +                String file = files[i].getName();
  +                if(files[i].isFile() && 
  +                    !(file.endsWith(".jar")||
  +                        file.endsWith(".zip")||
  +                        file.endsWith(".war")||
  +                        file.endsWith(".ear")||
  +                        file.endsWith(".java"))
  +                    ){
  +                        module.addFileToJar(file,files[i]);
                   }
  +                        
               }
  +        }
                   
  -            dir = new File(outDir,"META-INF");
  -            files = dir.listFiles();
  -            if(files != null){
  -                for(int i = 0;i<files.length;i++){
  -                    String file = files[i].getName();
  -                    if(files[i].isFile() && 
  -                        !(file.endsWith(".jar")||
  -                            file.endsWith(".zip")||
  -                            file.endsWith(".war")||
  -                            file.endsWith(".ear")||
  -                            file.endsWith(".java"))
  -                        ){
  -                            module.addFileToJar("META-INF/"+file,files[i]);
  -                    }
  -                        
  +        dir = new File(outDir,"META-INF");
  +        files = dir.listFiles();
  +        if(files != null){
  +            for(int i = 0;i<files.length;i++){
  +                String file = files[i].getName();
  +                if(files[i].isFile() && 
  +                    !(file.endsWith(".jar")||
  +                        file.endsWith(".zip")||
  +                        file.endsWith(".war")||
  +                        file.endsWith(".ear")||
  +                        file.endsWith(".java"))
  +                    ){
  +                        module.addFileToJar("META-INF/"+file,files[i]);
                   }
  +                        
               }
  +        }
   
  -            module.finalizeJar();
  +        module.finalizeJar();
  +    
  +    }
  +    private void compile(File outDir,File destDir) throws IOException{
  +        Project project = new Project();
  +        project.init();
  +        project.setCoreLoader(Thread.currentThread().getContextClassLoader());
  +                
  +                
  +        Javac comp = new Javac();
  +        comp.setProject(project);
               
               
  -        }catch(IOException e){
  -            throw GenerationFault.createGenerationFault(e);
  -        }catch(ClassNotFoundException e){
  -            System.out.println("Ant file will not be run programatcally as the " +
  -                "$JAVA_HOME/lib/tool.jar is not in the class path. To run the ant " +
  -                "prgramatically add that jar to classpath");
  -//NOW as the code is used by Geronimo we can not afford to let the build
  -//failure tests beside if you use maven it works fine. it will find your maven 
  -//repository itself :) 
  -//        }catch(BuildException e){
  -//          System.out.println(e.getMessage() +
  -//          "if it is a compile error you may not have set the maven reposiroty " +
  -//          "directory in the conf/ws4j2ee.propertites Build fill ignore the faliure");
  +        destDir.mkdirs();
  +        comp.setDestdir(destDir);
  +                
  +        Path path = new Path(project);
  +        path.setLocation(outDir);
  +        comp.setSrcdir(path);
  +        
  +        File repository = findMavenRepository();
  +        if(repository != null){
  +            Path compileClasspath = new Path(project);
  +            FileSet fileset = new FileSet();
  +            fileset.setDir(repository);
  +            fileset.setIncludes("axis/**/*.jar");
  +            fileset.setIncludes("geronimo-spec/**/*.jar");
  +            fileset.setIncludes("geronimo/**/*.jar");
  +            fileset.setIncludes("sec/**/*.jar");
  +            fileset.setIncludes("dom4j/**/*.jar");
  +            fileset.setIncludes("jaxb-ri/**/*.jar");
  +            fileset.setIncludes("xerces/**/*.jar");
  +            fileset.setIncludes("ews/**/*.jar");
  +            fileset.setIncludes("openejb/**/*.jar");
  +            compileClasspath.addFileset(fileset);
  +            comp.setClasspath(compileClasspath);
  +        }else{
  +            
  +        }
  +                        
  +        comp.init();
  +        comp.execute();
  +    
  +    }
  +    
  +    private File findMavenRepository() throws IOException{
  +        Properties pro = new Properties();
  +        InputStream prpertyIn = null;
  +        File file = new File(GenerationConstants.WS4J2EE_PROPERTY_FILE);
  +        if(file.exists()){
  +            prpertyIn = new FileInputStream(file);
  +        }else{
  +            file = new File("modules/axis/target/"+GenerationConstants.WS4J2EE_PROPERTY_FILE);
  +            if(file.exists()){
  +                prpertyIn = new FileInputStream(file);
  +            }else{
  +                file = new File("target/"+GenerationConstants.WS4J2EE_PROPERTY_FILE);
  +                if(file.exists()){
  +                    prpertyIn = new FileInputStream(file);
  +                }else{
  +                    prpertyIn = getClass().getClassLoader().getResourceAsStream(GenerationConstants.WS4J2EE_PROPERTY_FILE);
  +                }               
  +            }
  +        }
  +        if(prpertyIn!= null){
  +            String location = null;
  +            try{
  +                pro.load(prpertyIn);
  +                location = pro.getProperty(GenerationConstants.MAVEN_LOCAL_REPOSITARY);
  +            }finally{
  +                prpertyIn.close();
  +            }
  +            if(location != null){
  +                File locationFile = new File(location);
  +                if(locationFile.exists()){
  +                    return locationFile;
  +                }
  +            }
  +            
  +
           }
  +        return null;
       }
       
       
  
  
  

Mime
View raw message