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 org.apache.maven.plugins.ear.util.ArtifactRepository;
22 import org.apache.maven.plugins.ear.util.ArtifactTypeMappingService;
23 import org.apache.maven.project.MavenProject;
24
25 /**
26 * Contains various runtime parameters used to customize the generated EAR file.
27 *
28 * @author <a href="snicoll@apache.org">Stephane Nicoll</a>
29 */
30 public class EarExecutionContext {
31 private String defaultLibBundleDir;
32
33 private JbossConfiguration jbossConfiguration;
34
35 private String outputFileNameMapping;
36
37 private ArtifactRepository artifactRepository;
38
39 /**
40 * @param project {@link MavenProject}
41 * @param mainArtifactId The artifactId.
42 * @param defaultLibBundleDir The defaultLibBundleDir.
43 * @param jbossConfiguration {@link JbossConfiguration}
44 * @param fileNameMappingName file name mapping.
45 * @param typeMappingService {@link ArtifactTypeMappingService}
46 */
47 public EarExecutionContext(
48 MavenProject project,
49 String mainArtifactId,
50 String defaultLibBundleDir,
51 JbossConfiguration jbossConfiguration,
52 String fileNameMappingName,
53 ArtifactTypeMappingService typeMappingService) {
54 initialize(
55 project,
56 mainArtifactId,
57 defaultLibBundleDir,
58 jbossConfiguration,
59 fileNameMappingName,
60 typeMappingService);
61 }
62
63 /**
64 * @return {@link #defaultLibBundleDir}
65 */
66 public String getDefaultLibBundleDir() {
67 return defaultLibBundleDir;
68 }
69
70 /**
71 * @return {@link #jbossConfiguration}
72 */
73 public boolean isJbossConfigured() {
74 return jbossConfiguration != null;
75 }
76
77 /**
78 * @return {@link #outputFileNameMapping}
79 */
80 public String getOutputFileNameMapping() {
81 return outputFileNameMapping;
82 }
83
84 /**
85 * @return {@link #artifactRepository}
86 */
87 public ArtifactRepository getArtifactRepository() {
88 return artifactRepository;
89 }
90
91 private void initialize(
92 MavenProject project,
93 String mainArtifactId,
94 String defaultLibBundleDir,
95 JbossConfiguration jbossConfiguration,
96 String outputFileNameMapping,
97 ArtifactTypeMappingService typeMappingService) {
98 this.artifactRepository = new ArtifactRepository(project.getArtifacts(), mainArtifactId, typeMappingService);
99 this.defaultLibBundleDir = defaultLibBundleDir;
100 this.jbossConfiguration = jbossConfiguration;
101 this.outputFileNameMapping = outputFileNameMapping;
102 }
103 }