001 package org.apache.maven.artifact.repository.metadata; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022 import org.apache.maven.artifact.Artifact; 023 import org.apache.maven.artifact.repository.ArtifactRepository; 024 025 /** 026 * Metadata for the artifact version directory of the repository. 027 * 028 * @author <a href="mailto:brett@apache.org">Brett Porter</a> 029 * @todo split instantiation (versioning, plugin mappings) from definition 030 */ 031 public class SnapshotArtifactRepositoryMetadata 032 extends AbstractRepositoryMetadata 033 { 034 private Artifact artifact; 035 036 public SnapshotArtifactRepositoryMetadata( Artifact artifact ) 037 { 038 super( createMetadata( artifact, null ) ); 039 this.artifact = artifact; 040 } 041 042 public SnapshotArtifactRepositoryMetadata( Artifact artifact, 043 Snapshot snapshot ) 044 { 045 super( createMetadata( artifact, createVersioning( snapshot ) ) ); 046 this.artifact = artifact; 047 } 048 049 public boolean storedInGroupDirectory() 050 { 051 return false; 052 } 053 054 public boolean storedInArtifactVersionDirectory() 055 { 056 return true; 057 } 058 059 public String getGroupId() 060 { 061 return artifact.getGroupId(); 062 } 063 064 public String getArtifactId() 065 { 066 return artifact.getArtifactId(); 067 } 068 069 public String getBaseVersion() 070 { 071 return artifact.getBaseVersion(); 072 } 073 074 public Object getKey() 075 { 076 return "snapshot " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getBaseVersion(); 077 } 078 079 public boolean isSnapshot() 080 { 081 return artifact.isSnapshot(); 082 } 083 084 public int getNature() 085 { 086 return isSnapshot() ? SNAPSHOT : RELEASE; 087 } 088 089 public ArtifactRepository getRepository() 090 { 091 return artifact.getRepository(); 092 } 093 094 public void setRepository( ArtifactRepository remoteRepository ) 095 { 096 artifact.setRepository( remoteRepository ); 097 } 098 }