1 package org.apache.maven.plugin.assembly.mojos;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.plugin.MojoExecutionException;
23 import org.apache.maven.plugin.MojoFailureException;
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.AssemblyArchiver;
27 import org.apache.maven.plugin.assembly.format.AssemblyFormattingException;
28 import org.apache.maven.plugin.assembly.io.AssemblyReadException;
29 import org.apache.maven.plugin.assembly.io.AssemblyReader;
30 import org.apache.maven.plugin.assembly.model.Assembly;
31
32 import java.util.List;
33
34
35
36
37 @Deprecated
38 public abstract class AbstractDirectoryMojo
39 extends AbstractAssemblyMojo
40 {
41 @Override
42 public void execute()
43 throws MojoExecutionException, MojoFailureException
44 {
45 final AssemblyReader reader = getAssemblyReader();
46
47 List<Assembly> assemblies;
48 try
49 {
50 assemblies = reader.readAssemblies( this );
51 }
52 catch ( final AssemblyReadException e )
53 {
54 throw new MojoExecutionException( "Error reading assembly descriptors: " + e.getMessage(), e );
55 }
56 catch ( final InvalidAssemblerConfigurationException e )
57 {
58 throw new MojoFailureException( reader, e.getMessage(), "Mojo configuration is invalid: " + e.getMessage() );
59 }
60
61 for ( Assembly assembly : assemblies )
62 {
63 createDirectory( assembly );
64 }
65 }
66
67 private void createDirectory( final Assembly assembly )
68 throws MojoExecutionException, MojoFailureException
69 {
70 final AssemblyArchiver archiver = getAssemblyArchiver();
71
72 String fullName = getFinalName();
73
74 if ( appendAssemblyId )
75 {
76 fullName = fullName + "-" + assembly.getId();
77 }
78 else if ( getClassifier() != null )
79 {
80 fullName = fullName + "-" + getClassifier();
81 }
82
83 try
84 {
85 archiver.createArchive( assembly, fullName, "dir", this, isRecompressZippedFiles() );
86 }
87 catch ( final ArchiveCreationException e )
88 {
89 throw new MojoExecutionException( "Error creating assembly: " + e.getMessage(), e );
90 }
91 catch ( final AssemblyFormattingException e )
92 {
93 throw new MojoExecutionException( "Error creating assembly: " + e.getMessage(), e );
94 }
95 catch ( final InvalidAssemblerConfigurationException e )
96 {
97 throw new MojoFailureException( assembly, "Assembly is incorrectly configured: " + assembly.getId(),
98 "Assembly: " + assembly.getId() + " is not configured correctly: "
99 + e.getMessage() );
100 }
101 }
102
103 }