View Javadoc
1   package org.codehaus.mojo.webstart.dependency.filenaming;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with work for additional information
7    * regarding copyright ownership.  The ASF licenses file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.commons.lang.StringUtils;
23  import org.apache.maven.artifact.Artifact;
24  import org.codehaus.plexus.component.annotations.Component;
25  
26  /**
27   * Provide a safe naming strategy that avoid any colision name.
28   * <p/>
29   * The syntax of this naming strategy:
30   * <pre>groupdId-artifactId[-classifier][(__V|.)version].extension</pre>
31   * <p/>
32   * Created on 1/6/14.
33   *
34   * @author Tony Chemit <chemit@codelutin.com>
35   * @since 1.0-beta-5
36   */
37  @Component(role = DependencyFilenameStrategy.class, hint = FullDependencyFilenameStrategy.ROLE_HINT)
38  public class FullDependencyFilenameStrategy
39      extends AbstractDependencyFilenameStrategy
40      implements DependencyFilenameStrategy
41  {
42  
43      public static final String ROLE_HINT = "full";
44  
45      /**
46       * {@inheritDoc}
47       */
48      public String getDependencyFileBasename( Artifact artifact, Boolean outputJarVersion, Boolean useUniqueVersions )
49      {
50          String filename = artifact.getGroupId() + "-" + artifact.getArtifactId();
51  
52          if ( outputJarVersion != null )
53          {
54  
55              if ( outputJarVersion )
56              {
57                  filename += "__V";
58              }
59              else
60              {
61                  filename += "-";
62              }
63              
64              if (useUniqueVersions != null && useUniqueVersions.booleanValue()) 
65              {
66              	filename += artifact.getBaseVersion();
67              }
68              else {
69              	filename += artifact.getVersion();
70              }
71          }
72  
73          if ( StringUtils.isNotEmpty( artifact.getClassifier() ) )
74          {
75              filename += "-" + artifact.getClassifier();
76          }
77          return filename;
78      }
79  }