1 /* 2 * $Id$ 3 */ 4 5 package org.apache.maven.model; 6 7 //---------------------------------/ 8 //- Imported classes and packages -/ 9 //---------------------------------/ 10 11 import java.util.Date; 12 13 /** 14 * 15 * 16 * The <code><parent></code> element contains 17 * informations required to the parent project. 18 * 19 * 20 * 21 * @version $Revision$ $Date$ 22 */ 23 public class Parent implements java.io.Serializable { 24 25 26 //--------------------------/ 27 //- Class/Member Variables -/ 28 //--------------------------/ 29 30 /** 31 * The artifact id of the parent project to inherit from. 32 */ 33 private String artifactId; 34 35 /** 36 * The group id of the parent project to inherit from. 37 */ 38 private String groupId; 39 40 /** 41 * The version of the parent project to inherit. 42 */ 43 private String version; 44 45 /** 46 * 47 * 48 * The relative path of the parent 49 * <code>pom.xml</code> file within the check out. 50 * The default value is <code>../pom.xml</code>. 51 * Maven looks for the parent pom first in the 52 * reactor of currently building projects, then in this 53 * location on 54 * the filesystem, then the local repository, and 55 * lastly in the remote repo. 56 * <code>relativePath</code> allows you to select a 57 * different location, 58 * for example when your structure is flat, or 59 * deeper without an intermediate parent pom. 60 * However, the group ID, artifact ID and version 61 * are still required, 62 * and must match the file in the location given or 63 * it will revert to the repository for the POM. 64 * This feature is only for enhancing the 65 * development in a local checkout of that project. 66 * 67 * 68 */ 69 private String relativePath = "../pom.xml"; 70 71 72 //-----------/ 73 //- Methods -/ 74 //-----------/ 75 76 /** 77 * Get the artifact id of the parent project to inherit from. 78 * 79 * @return String 80 */ 81 public String getArtifactId() 82 { 83 return this.artifactId; 84 } //-- String getArtifactId() 85 86 /** 87 * Get the group id of the parent project to inherit from. 88 * 89 * @return String 90 */ 91 public String getGroupId() 92 { 93 return this.groupId; 94 } //-- String getGroupId() 95 96 /** 97 * Get 98 * 99 * The relative path of the parent 100 * <code>pom.xml</code> file within the check out. 101 * The default value is <code>../pom.xml</code>. 102 * Maven looks for the parent pom first in the 103 * reactor of currently building projects, then in this 104 * location on 105 * the filesystem, then the local repository, and 106 * lastly in the remote repo. 107 * <code>relativePath</code> allows you to select a 108 * different location, 109 * for example when your structure is flat, or 110 * deeper without an intermediate parent pom. 111 * However, the group ID, artifact ID and version 112 * are still required, 113 * and must match the file in the location given or 114 * it will revert to the repository for the POM. 115 * This feature is only for enhancing the 116 * development in a local checkout of that project. 117 * 118 * 119 * 120 * @return String 121 */ 122 public String getRelativePath() 123 { 124 return this.relativePath; 125 } //-- String getRelativePath() 126 127 /** 128 * Get the version of the parent project to inherit. 129 * 130 * @return String 131 */ 132 public String getVersion() 133 { 134 return this.version; 135 } //-- String getVersion() 136 137 /** 138 * Set the artifact id of the parent project to inherit from. 139 * 140 * @param artifactId 141 */ 142 public void setArtifactId( String artifactId ) 143 { 144 this.artifactId = artifactId; 145 } //-- void setArtifactId( String ) 146 147 /** 148 * Set the group id of the parent project to inherit from. 149 * 150 * @param groupId 151 */ 152 public void setGroupId( String groupId ) 153 { 154 this.groupId = groupId; 155 } //-- void setGroupId( String ) 156 157 /** 158 * Set 159 * 160 * The relative path of the parent 161 * <code>pom.xml</code> file within the check out. 162 * The default value is <code>../pom.xml</code>. 163 * Maven looks for the parent pom first in the 164 * reactor of currently building projects, then in this 165 * location on 166 * the filesystem, then the local repository, and 167 * lastly in the remote repo. 168 * <code>relativePath</code> allows you to select a 169 * different location, 170 * for example when your structure is flat, or 171 * deeper without an intermediate parent pom. 172 * However, the group ID, artifact ID and version 173 * are still required, 174 * and must match the file in the location given or 175 * it will revert to the repository for the POM. 176 * This feature is only for enhancing the 177 * development in a local checkout of that project. 178 * 179 * 180 * 181 * @param relativePath 182 */ 183 public void setRelativePath( String relativePath ) 184 { 185 this.relativePath = relativePath; 186 } //-- void setRelativePath( String ) 187 188 /** 189 * Set the version of the parent project to inherit. 190 * 191 * @param version 192 */ 193 public void setVersion( String version ) 194 { 195 this.version = version; 196 } //-- void setVersion( String ) 197 198 199 200 /** 201 * @return the id as <code>groupId:artifactId:version</code> 202 */ 203 public String getId() 204 { 205 StringBuffer id = new StringBuffer(); 206 207 id.append( getGroupId() ); 208 id.append( ":" ); 209 id.append( getArtifactId() ); 210 id.append( ":" ); 211 id.append( "pom" ); 212 // id.append( getPackaging() ); 213 id.append( ":" ); 214 id.append( getVersion() ); 215 216 return id.toString(); 217 } 218 219 220 private String modelEncoding = "UTF-8"; 221 222 /** 223 * Set an encoding used for reading/writing the model. 224 * 225 * @param modelEncoding the encoding used when reading/writing the model. 226 */ 227 public void setModelEncoding( String modelEncoding ) 228 { 229 this.modelEncoding = modelEncoding; 230 } 231 232 /** 233 * @return the current encoding used when reading/writing this model. 234 */ 235 public String getModelEncoding() 236 { 237 return modelEncoding; 238 } 239 }