View Javadoc
1   package org.apache.maven.plugin.eclipse.writers;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.List;
23  
24  import org.apache.maven.plugin.logging.Log;
25  import org.codehaus.plexus.util.xml.XMLWriter;
26  
27  /**
28   * Writes an external ant launch file.
29   * 
30   * @author <a href="mailto:kenneyw@neonics.com">Kenney Westerhof</a>
31   */
32  public class EclipseAntExternalLaunchConfigurationWriter
33      extends EclipseLaunchConfigurationWriter
34  {
35      private String buildfilePath;
36  
37      /**
38       * @param launcherName Name of the launch file, for instance 'AntBuilder.launch'
39       * @param buildfilePath Project relative path to the ant build file, for instance 'eclipse-build.xml'
40       * @return this
41       */
42      public EclipseWriter init( Log log, EclipseWriterConfig config, String launcherName, String buildfilePath )
43      {
44          this.buildfilePath = buildfilePath;
45          return super.init( log, config, launcherName );
46      }
47  
48      protected void addAttributes( XMLWriter writer )
49      {
50          // ant specific
51          writeAttribute( writer, "process_factory_id", "org.eclipse.ant.ui.remoteAntProcessFactory" );
52  
53          writeAttribute( writer, "org.eclipse.ant.ui.DEFAULT_VM_INSTALL", false );
54  
55          writeAttribute( writer, "org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON", false );
56  
57          writeAttribute( writer, "org.eclipse.ant.ui.ATTR_TARGETS_UPDATED", true );
58  
59          writeAttribute( writer, "org.eclipse.jdt.launching.CLASSPATH_PROVIDER",
60                          "org.eclipse.ant.ui.AntClasspathProvider" );
61  
62          writeAttribute( writer, "org.eclipse.debug.core.MAPPED_RESOURCE_TYPES", new String[] { "1" } );
63  
64          writeAttribute( writer, "org.eclipse.debug.core.MAPPED_RESOURCE_PATHS",
65                          new String[] { "/" + config.getEclipseProjectName() + "/" + buildfilePath } );
66      }
67  
68      protected String getLaunchConfigurationType()
69      {
70          return "org.eclipse.ant.AntBuilderLaunchConfigurationType";
71      }
72  
73      protected String getBuilderLocation()
74      {
75          return "${build_project}/" + buildfilePath;
76      }
77  
78      protected List getMonitoredResources()
79      {
80          // TODO: return a list of MonitoredResources that encapsulate
81          // the resource locations - includes/excludes aren't supported
82          // so we need to just add the directories.
83          return super.getMonitoredResources();
84      }
85  }