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.

LegacyRepositoryLayout.java 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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.handler.ArtifactHandler;
  22. import org.apache.maven.artifact.metadata.ArtifactMetadata;
  23. import org.apache.maven.artifact.repository.ArtifactRepository;
  24. import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
  25. import org.codehaus.plexus.component.annotations.Component;
  26. /**
  27. * @author jdcasey
  28. */
  29. @Component( role = ArtifactRepositoryLayout.class, hint = "legacy")
  30. public class LegacyRepositoryLayout
  31. implements ArtifactRepositoryLayout
  32. {
  33. private static final String PATH_SEPARATOR = "/";
  34. public String getId()
  35. {
  36. return "legacy";
  37. }
  38. @Override
  39. public String pathOf( Artifact artifact )
  40. {
  41. ArtifactHandler artifactHandler = artifact.getArtifactHandler();
  42. StringBuilder path = new StringBuilder( 128 );
  43. path.append( artifact.getGroupId() ).append( '/' );
  44. path.append( artifactHandler.getDirectory() ).append( '/' );
  45. path.append( artifact.getArtifactId() ).append( '-' ).append( artifact.getVersion() );
  46. if ( artifact.hasClassifier() )
  47. {
  48. path.append( '-' ).append( artifact.getClassifier() );
  49. }
  50. if ( artifactHandler.getExtension() != null && artifactHandler.getExtension().length() > 0 )
  51. {
  52. path.append( '.' ).append( artifactHandler.getExtension() );
  53. }
  54. return path.toString();
  55. }
  56. @Override
  57. public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
  58. {
  59. return pathOfRepositoryMetadata( metadata, metadata.getLocalFilename( repository ) );
  60. }
  61. private String pathOfRepositoryMetadata( ArtifactMetadata metadata, String filename )
  62. {
  63. StringBuilder path = new StringBuilder( 128 );
  64. path.append( metadata.getGroupId() ).append( PATH_SEPARATOR ).append( "poms" ).append( PATH_SEPARATOR );
  65. path.append( filename );
  66. return path.toString();
  67. }
  68. @Override
  69. public String pathOfRemoteRepositoryMetadata( ArtifactMetadata metadata )
  70. {
  71. return pathOfRepositoryMetadata( metadata, metadata.getRemoteFilename() );
  72. }
  73. }