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.plugins.ear;
20
21 import java.util.Set;
22
23 import org.apache.maven.artifact.Artifact;
24 import org.apache.maven.plugin.MojoFailureException;
25 import org.codehaus.plexus.util.xml.XMLWriter;
26
27 /**
28 * The ear module interface.
29 *
30 * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
31 */
32 public interface EarModule {
33
34 /**
35 * Returns the {@link Artifact} representing this module.
36 *
37 * Note that this might return {@code null} till the module has been resolved.
38 *
39 * @return the artifact
40 * @see #resolveArtifact(java.util.Set)
41 */
42 Artifact getArtifact();
43
44 /**
45 * Returns the {@code URI} for this module.
46 *
47 * @return the {@code URI}
48 */
49 String getUri();
50
51 /**
52 * Returns the type associated to the module.
53 *
54 * @return the artifact's type of the module
55 */
56 String getType();
57
58 /**
59 * Specify whether this module should be excluded or not.
60 *
61 * @return true if this module should be skipped, false otherwise
62 */
63 boolean isExcluded();
64
65 /**
66 * Specify whether this module should be unpacked in the EAR archive or not.
67 *
68 * Returns null if no configuration was specified so that defaulting may apply.
69 *
70 * @return true if this module should be bundled unpacked, false otherwise
71 */
72 Boolean shouldUnpack();
73
74 /**
75 * The alt-dd element specifies an optional URI to the post-assembly version of the deployment descriptor file for a
76 * particular Java EE module. The URI must specify the full pathname of the deployment descriptor file relative to
77 * the application's root directory.
78 *
79 * @return the alternative deployment descriptor for this module
80 * @since JavaEE 5
81 */
82 String getAltDeploymentDescriptor();
83
84 /**
85 * Appends the {@code XML} representation of this module.
86 *
87 * @param writer the writer to use
88 * @param version the version of the {@code application.xml} file
89 * @param generateId whether an id should be generated
90 */
91 void appendModule(XMLWriter writer, String version, Boolean generateId);
92
93 /**
94 * Resolves the {@link Artifact} represented by the module. Note that the {@link EarExecutionContext} might be used
95 * to customize further the resolution.
96 *
97 * @param artifacts the project's artifacts
98 * @throws EarPluginException if the artifact could not be resolved
99 * @throws MojoFailureException if an unexpected error occurred
100 */
101 void resolveArtifact(Set<Artifact> artifacts) throws EarPluginException, MojoFailureException;
102
103 /**
104 * @param earExecutionContext The execution context.
105 */
106 void setEarExecutionContext(EarExecutionContext earExecutionContext);
107
108 /**
109 * @return the state if manifest classpath will be changed or not.
110 */
111 boolean changeManifestClasspath();
112
113 /**
114 * @return The directory of the module which contains the JAR libraries packaged within the module.
115 * Can be {@code null}, which means that module doesn't contain any packaged libraries.
116 */
117 String getLibDir();
118
119 /**
120 * Returns the bundle file name. If {@code null}, the artifact's file name is returned.
121 *
122 * @return the bundle file name
123 */
124 String getBundleFileName();
125
126 /**
127 * If module should be included into the Class-Path entry of MANIFEST.mf. Doesn't impact Class-Path entry of
128 * MANIFEST.mf of modules which contain all of their dependencies unless skinnyWars / skinnyModules is turned on.
129 *
130 * @return {@code }True} if module should be included into the Class-Path entry of MANIFEST.mf
131 */
132 boolean isClassPathItem();
133 }