001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019package org.apache.maven.tools.plugin; 020 021import java.util.List; 022import java.util.Map; 023import java.util.Objects; 024import java.util.Set; 025 026import org.apache.maven.artifact.Artifact; 027import org.apache.maven.model.Plugin; 028import org.apache.maven.plugin.descriptor.DuplicateMojoDescriptorException; 029import org.apache.maven.plugin.descriptor.MojoDescriptor; 030import org.apache.maven.plugin.descriptor.PluginDescriptor; 031import org.codehaus.plexus.classworlds.realm.ClassRealm; 032 033/** 034 * Extensions to {@link PluginDescriptor} not supported by Maven 3.2.5. 035 * This is a wrapper around an existing PluginDescriptor. 036 */ 037public class ExtendedPluginDescriptor extends PluginDescriptor { 038 private final PluginDescriptor delegate; 039 private String requiredJavaVersion; 040 041 public ExtendedPluginDescriptor(PluginDescriptor delegate) { 042 this.delegate = delegate; 043 // populate the fields feeding the final methods of ComponentSetDescriptor 044 // which can't be overridden by this wrapper 045 this.setIsolatedRealm(delegate.isIsolatedRealm()); 046 this.setDependencies(delegate.getDependencies()); 047 this.setComponents(delegate.getComponents()); 048 } 049 050 public void setRequiredJavaVersion(String requiredJavaVersion) { 051 this.requiredJavaVersion = requiredJavaVersion; 052 } 053 054 public String getRequiredJavaVersion() { 055 return requiredJavaVersion; 056 } 057 058 @Override 059 public boolean equals(Object obj) { 060 if (this == obj) { 061 return true; 062 } 063 if (!super.equals(obj)) { 064 return false; 065 } 066 if (getClass() != obj.getClass()) { 067 return false; 068 } 069 ExtendedPluginDescriptor other = (ExtendedPluginDescriptor) obj; 070 return Objects.equals(delegate, other.delegate) 071 && Objects.equals(requiredJavaVersion, other.requiredJavaVersion); 072 } 073 074 @Override 075 public int hashCode() { 076 final int prime = 31; 077 int result = super.hashCode(); 078 result = prime * result + Objects.hash(delegate, requiredJavaVersion); 079 return result; 080 } 081 082 /* -- START delegate methods --*/ 083 public List<MojoDescriptor> getMojos() { 084 return delegate.getMojos(); 085 } 086 087 public void addMojo(MojoDescriptor mojoDescriptor) throws DuplicateMojoDescriptorException { 088 delegate.addMojo(mojoDescriptor); 089 } 090 091 public void addMojos(List<MojoDescriptor> mojos) throws DuplicateMojoDescriptorException { 092 for (MojoDescriptor mojoDescriptor : mojos) { 093 addMojo(mojoDescriptor); 094 } 095 } 096 097 public String getGroupId() { 098 return delegate.getGroupId(); 099 } 100 101 public void setGroupId(String groupId) { 102 delegate.setGroupId(groupId); 103 } 104 105 public String getArtifactId() { 106 return delegate.getArtifactId(); 107 } 108 109 public void setArtifactId(String artifactId) { 110 delegate.setArtifactId(artifactId); 111 } 112 113 public String getPluginLookupKey() { 114 return delegate.getPluginLookupKey(); 115 } 116 117 public String getId() { 118 return delegate.getId(); 119 } 120 121 public String getGoalPrefix() { 122 return delegate.getGoalPrefix(); 123 } 124 125 public void setGoalPrefix(String goalPrefix) { 126 delegate.setGoalPrefix(goalPrefix); 127 } 128 129 public void setVersion(String version) { 130 delegate.setVersion(version); 131 } 132 133 public String getVersion() { 134 return delegate.getVersion(); 135 } 136 137 public void setSource(String source) { 138 delegate.setSource(source); 139 } 140 141 public String getSource() { 142 return delegate.getSource(); 143 } 144 145 public boolean isInheritedByDefault() { 146 return delegate.isInheritedByDefault(); 147 } 148 149 public void setInheritedByDefault(boolean inheritedByDefault) { 150 delegate.setInheritedByDefault(inheritedByDefault); 151 } 152 153 public List<Artifact> getArtifacts() { 154 return delegate.getArtifacts(); 155 } 156 157 public void setArtifacts(List<Artifact> artifacts) { 158 delegate.setArtifacts(artifacts); 159 } 160 161 public Map<String, Artifact> getArtifactMap() { 162 return delegate.getArtifactMap(); 163 } 164 165 public MojoDescriptor getMojo(String goal) { 166 return delegate.getMojo(goal); 167 } 168 169 public void setClassRealm(ClassRealm classRealm) { 170 delegate.setClassRealm(classRealm); 171 } 172 173 public ClassRealm getClassRealm() { 174 return delegate.getClassRealm(); 175 } 176 177 public void setIntroducedDependencyArtifacts(Set<Artifact> introducedDependencyArtifacts) { 178 delegate.setIntroducedDependencyArtifacts(introducedDependencyArtifacts); 179 } 180 181 public Set<Artifact> getIntroducedDependencyArtifacts() { 182 return delegate.getIntroducedDependencyArtifacts(); 183 } 184 185 public void setName(String name) { 186 delegate.setName(name); 187 } 188 189 public String getName() { 190 return delegate.getName(); 191 } 192 193 public void setDescription(String description) { 194 delegate.setDescription(description); 195 } 196 197 public String getDescription() { 198 return delegate.getDescription(); 199 } 200 201 public void setRequiredMavenVersion(String requiredMavenVersion) { 202 delegate.setRequiredMavenVersion(requiredMavenVersion); 203 } 204 205 public String getRequiredMavenVersion() { 206 return delegate.getRequiredMavenVersion(); 207 } 208 209 public void setPlugin(Plugin plugin) { 210 delegate.setPlugin(plugin); 211 } 212 213 @Override 214 public Plugin getPlugin() { 215 return delegate.getPlugin(); 216 } 217 218 @Override 219 public Artifact getPluginArtifact() { 220 return delegate.getPluginArtifact(); 221 } 222 223 @Override 224 public void setPluginArtifact(Artifact pluginArtifact) { 225 delegate.setPluginArtifact(pluginArtifact); 226 } 227 228 public PluginDescriptor clone() { 229 return delegate.clone(); 230 } 231}