You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SnapshotArtifactRepositoryMetadata.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. package org.apache.archiva.converter.artifact;
  2. /*
  3. * Licensed to the Apache Software Foundation (ASF) under one
  4. * or more contributor license agreements. See the NOTICE file
  5. * distributed with this work for additional information
  6. * regarding copyright ownership. The ASF licenses this file
  7. * to you under the Apache License, Version 2.0 (the
  8. * "License"); you may not use this file except in compliance
  9. * with the License. You may obtain a copy of the License at
  10. *
  11. * http://www.apache.org/licenses/LICENSE-2.0
  12. *
  13. * Unless required by applicable law or agreed to in writing,
  14. * software distributed under the License is distributed on an
  15. * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  16. * KIND, either express or implied. See the License for the
  17. * specific language governing permissions and limitations
  18. * under the License.
  19. */
  20. import org.apache.maven.artifact.Artifact;
  21. import org.apache.maven.artifact.repository.ArtifactRepository;
  22. import org.apache.maven.artifact.repository.metadata.AbstractRepositoryMetadata;
  23. import org.apache.maven.artifact.repository.metadata.Snapshot;
  24. /**
  25. *
  26. * This is a copy of org.apache.maven.artifact.repository.metadata.SnapshotArtifactRepositoryMetadata
  27. * from the maven-compat module, because this is the only class that we use from the compat module and
  28. * we can get rid of the dependency.
  29. *
  30. * Metadata for the artifact version directory of the repository.
  31. *
  32. *
  33. * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  34. *
  35. */
  36. public class SnapshotArtifactRepositoryMetadata
  37. extends AbstractRepositoryMetadata
  38. {
  39. private Artifact artifact;
  40. public SnapshotArtifactRepositoryMetadata( Artifact artifact )
  41. {
  42. super( createMetadata( artifact, null ) );
  43. this.artifact = artifact;
  44. }
  45. public SnapshotArtifactRepositoryMetadata( Artifact artifact,
  46. Snapshot snapshot )
  47. {
  48. super( createMetadata( artifact, createVersioning( snapshot ) ) );
  49. this.artifact = artifact;
  50. }
  51. public boolean storedInGroupDirectory()
  52. {
  53. return false;
  54. }
  55. public boolean storedInArtifactVersionDirectory()
  56. {
  57. return true;
  58. }
  59. public String getGroupId()
  60. {
  61. return artifact.getGroupId();
  62. }
  63. public String getArtifactId()
  64. {
  65. return artifact.getArtifactId();
  66. }
  67. public String getBaseVersion()
  68. {
  69. return artifact.getBaseVersion();
  70. }
  71. public Object getKey()
  72. {
  73. return "snapshot " + artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getBaseVersion();
  74. }
  75. public boolean isSnapshot()
  76. {
  77. return artifact.isSnapshot();
  78. }
  79. public int getNature()
  80. {
  81. return isSnapshot() ? SNAPSHOT : RELEASE;
  82. }
  83. public ArtifactRepository getRepository()
  84. {
  85. return artifact.getRepository();
  86. }
  87. public void setRepository( ArtifactRepository remoteRepository )
  88. {
  89. artifact.setRepository( remoteRepository );
  90. }
  91. }