View Javadoc

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