KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > tool > core > JarFileWriter


1 package org.apache.axis.tool.core;
2
3 import java.io.File JavaDoc;
4 import java.io.IOException JavaDoc;
5
6 import org.apache.tools.ant.Project;
7 import org.apache.tools.ant.taskdefs.Jar;
8
9 /*
10  * Copyright 2004,2005 The Apache Software Foundation.
11  *
12  * Licensed under the Apache License, Version 2.0 (the "License");
13  * you may not use this file except in compliance with the License.
14  * You may obtain a copy of the License at
15  *
16  * http://www.apache.org/licenses/LICENSE-2.0
17  *
18  * Unless required by applicable law or agreed to in writing, software
19  * distributed under the License is distributed on an "AS IS" BASIS,
20  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21  * See the License for the specific language governing permissions and
22  * limitations under the License.
23  */

24 public class JarFileWriter extends Jar{
25
26
27     public JarFileWriter() {
28         this.setProject(new Project());
29         this.getProject().init();
30         this.setTaskType("jar");
31         this.setTaskName("jar");
32         this.setOwningTarget(new org.apache.tools.ant.Target());
33     }
34
35     public void writeJarFile(File JavaDoc outputFolder,String JavaDoc outputFileName,File JavaDoc inputFileFolder) throws IOException JavaDoc,Exception JavaDoc {
36
37         if (!outputFolder.exists()){
38             outputFolder.mkdir(); //create the output path
39
}else{
40             if (!outputFolder.isDirectory())
41                 return;
42         }
43
44         File JavaDoc targetFile = new File JavaDoc(outputFolder,outputFileName);
45         this.setBasedir(inputFileFolder);
46         this.setDestFile(targetFile);
47
48         //run the task
49
this.perform();
50
51
52     }
53
54
55 }
56
Popular Tags