View Javadoc

1   package org.apache.maven.plugin.assembly.archive.phase;
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 org.apache.maven.plugin.assembly.AssemblerConfigurationSource;
23  import org.apache.maven.plugin.assembly.AssemblyContext;
24  import org.apache.maven.plugin.assembly.InvalidAssemblerConfigurationException;
25  import org.apache.maven.plugin.assembly.archive.ArchiveCreationException;
26  import org.apache.maven.plugin.assembly.archive.task.AddDependencySetsTask;
27  import org.apache.maven.plugin.assembly.format.AssemblyFormattingException;
28  import org.apache.maven.plugin.assembly.model.Assembly;
29  import org.apache.maven.project.MavenProjectBuilder;
30  import org.codehaus.plexus.archiver.Archiver;
31  import org.codehaus.plexus.archiver.manager.ArchiverManager;
32  import org.codehaus.plexus.logging.AbstractLogEnabled;
33  import org.codehaus.plexus.logging.Logger;
34  
35  /**
36   * Handles the top-level <dependencySets/> section of the assembly descriptor.
37   * 
38   * @version $Id: DependencySetAssemblyPhase.java 1002307 2010-09-28 18:13:44Z jdcasey $
39   * @plexus.component role="org.apache.maven.plugin.assembly.archive.phase.AssemblyArchiverPhase"
40   *                   role-hint="dependency-sets"
41   */
42  public class DependencySetAssemblyPhase
43      extends AbstractLogEnabled
44      implements AssemblyArchiverPhase
45  {
46  
47      /**
48       * @plexus.requirement
49       */
50      private MavenProjectBuilder projectBuilder;
51  
52      /**
53       * @plexus.requirement
54       */
55      private ArchiverManager archiverManager;
56  
57      public DependencySetAssemblyPhase()
58      {
59          // used for plexus init
60      }
61  
62      public DependencySetAssemblyPhase( final MavenProjectBuilder projectBuilder, final Logger logger )
63      {
64          this.projectBuilder = projectBuilder;
65          enableLogging( logger );
66      }
67  
68      /**
69       * {@inheritDoc}
70       */
71      public void execute( final Assembly assembly, final Archiver archiver,
72                           final AssemblerConfigurationSource configSource, final AssemblyContext context )
73          throws ArchiveCreationException, AssemblyFormattingException, InvalidAssemblerConfigurationException
74      {
75          final AddDependencySetsTask task =
76              new AddDependencySetsTask( assembly.getDependencySets(), context.getResolvedArtifacts(),
77                                         configSource.getProject(), projectBuilder, archiverManager, getLogger() );
78  
79          task.execute( archiver, configSource );
80      }
81  }