001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.pluto.maven;
018:
019: import java.io.IOException;
020: import java.util.ArrayList;
021: import java.util.Collection;
022: import java.util.Collections;
023: import java.util.List;
024: import java.util.Properties;
025:
026: /**
027: *
028: */
029: class InstallationDependency {
030:
031: private static final Properties VERSION_PROPERTIES = new Properties();
032: private static final String PROPERTIES_FILE = "/versions.properties";
033: static {
034: try {
035: VERSION_PROPERTIES.load(InstallationDependency.class
036: .getResourceAsStream(PROPERTIES_FILE));
037: } catch (IOException e) {
038: throw new RuntimeException("Cannot load " + PROPERTIES_FILE
039: + " from the classpath!", e);
040: }
041: }
042:
043: public static final InstallationDependency PORTLET_API = new InstallationDependency(
044: "javax.portlet", "portlet-api", VERSION_PROPERTIES
045: .getProperty("portlet-api.version"));
046:
047: public static final InstallationDependency DESCRIPTOR_API = new InstallationDependency(
048: "org.apache.pluto", "pluto-descriptor-api",
049: VERSION_PROPERTIES.getProperty("pluto.version"));
050:
051: public static final InstallationDependency DESCRIPTOR_IMPL = new InstallationDependency(
052: "org.apache.pluto", "pluto-descriptor-impl",
053: VERSION_PROPERTIES.getProperty("pluto.version"));
054:
055: public static final InstallationDependency CONTAINER = new InstallationDependency(
056: "org.apache.pluto", "pluto-container", VERSION_PROPERTIES
057: .getProperty("pluto.version"));
058:
059: public static final InstallationDependency TAGLIB = new InstallationDependency(
060: "org.apache.pluto", "pluto-taglib", VERSION_PROPERTIES
061: .getProperty("pluto.version"));
062:
063: public static final InstallationDependency PORTAL = new InstallationDependency(
064: "org.apache.pluto", "pluto-portal", VERSION_PROPERTIES
065: .getProperty("pluto.version"), "war");
066:
067: public static final InstallationDependency TESTSUITE = new InstallationDependency(
068: "org.apache.pluto", "pluto-testsuite", VERSION_PROPERTIES
069: .getProperty("pluto.version"), "war");
070:
071: public static final InstallationDependency CASTOR = new InstallationDependency(
072: "org.codehaus.castor", "castor", VERSION_PROPERTIES
073: .getProperty("castor.version"));
074:
075: public static final InstallationDependency COMMONS_LOGGING_API = new InstallationDependency(
076: "commons-logging", "commons-logging-api",
077: VERSION_PROPERTIES.getProperty("commons-logging.version"));
078:
079: public static final InstallationDependency XERCES = new InstallationDependency(
080: "xerces", "xercesImpl", VERSION_PROPERTIES
081: .getProperty("xercesImpl.version"));
082:
083: public static final InstallationDependency XML_PARSER_APIS = new InstallationDependency(
084: "xerces", "xmlParserAPIs", VERSION_PROPERTIES
085: .getProperty("xmlParserAPIs.version"));
086:
087: private static final List ENDORSED = new ArrayList();
088: private static final List SHARED = new ArrayList();
089:
090: static {
091: ENDORSED.add(XERCES);
092: ENDORSED.add(XML_PARSER_APIS);
093:
094: SHARED.add(PORTLET_API);
095: SHARED.add(DESCRIPTOR_API);
096: SHARED.add(DESCRIPTOR_IMPL);
097: SHARED.add(CONTAINER);
098: SHARED.add(TAGLIB);
099: SHARED.add(CASTOR);
100: SHARED.add(COMMONS_LOGGING_API);
101: }
102:
103: public static Collection getEndorsedDependencies() {
104: return Collections.unmodifiableCollection(ENDORSED);
105: }
106:
107: public static Collection getSharedDependencies() {
108: return Collections.unmodifiableCollection(SHARED);
109: }
110:
111: private String groupId;
112: private String artifactId;
113: private String version;
114: private String type;
115:
116: public InstallationDependency(String groupId, String artifactId,
117: String version) {
118: this (groupId, artifactId, version, "jar");
119: }
120:
121: public InstallationDependency(String groupId, String artifactId,
122: String version, String type) {
123: if (version == null || version.trim().equalsIgnoreCase("")) {
124: throw new RuntimeException(
125: "Missing or invalid property for artifact "
126: + artifactId + " in " + PROPERTIES_FILE
127: + "!");
128: }
129:
130: this .groupId = groupId;
131: this .artifactId = artifactId;
132: this .version = version;
133: this .type = type;
134: }
135:
136: public String getGroupId() {
137: return groupId;
138: }
139:
140: public void setGroupId(String groupId) {
141: this .groupId = groupId;
142: }
143:
144: public String getArtifactId() {
145: return artifactId;
146: }
147:
148: public void setArtifactId(String artifactId) {
149: this .artifactId = artifactId;
150: }
151:
152: public String getVersion() {
153: return version;
154: }
155:
156: public void setVersion(String version) {
157: this .version = version;
158: }
159:
160: public String getType() {
161: return type;
162: }
163:
164: public void setType(String type) {
165: this.type = type;
166: }
167:
168: }
|