View Javadoc

1   package org.apache.maven.simian;
2   
3   /* ====================================================================
4    *   Copyright 2001-2004 The Apache Software Foundation.
5    *
6    *   Licensed under the Apache License, Version 2.0 (the "License");
7    *   you may not use this file except in compliance with the License.
8    *   You may obtain a copy of the License at
9    *
10   *       http://www.apache.org/licenses/LICENSE-2.0
11   *
12   *   Unless required by applicable law or agreed to in writing, software
13   *   distributed under the License is distributed on an "AS IS" BASIS,
14   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   *   See the License for the specific language governing permissions and
16   *   limitations under the License.
17   * ====================================================================
18   */
19  
20  import au.com.redhillconsulting.simian.SimianTask;
21  
22  import org.apache.tools.ant.BuildException;
23  
24  import java.io.File;
25  import java.io.FileNotFoundException;
26  import java.io.FileOutputStream;
27  
28  /**
29   * Simian Task that writes the output to a file.
30   *
31   * @author Aslak Hellesoy
32   * @version $Revision: 371231 $
33   */
34  public class FileSimianTask extends SimianTask
35  {
36      /**
37       * Make sure the directory structure exists and
38       * send the output to a specified file.
39       */
40      public void setOutput( File output )
41      {
42          output.getParentFile().mkdirs();
43  
44          try
45          {
46              setOutput( new FileOutputStream( output ) );
47          }
48          catch ( FileNotFoundException e )
49          {
50              throw new BuildException( "Couldn't set output to "
51                  + output.getAbsolutePath(), e );
52          }
53      }
54  }