View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.buildcache.artifact;
20  
21  public enum OutputType {
22      // generated project artifact
23      ARTIFACT(""),
24      // generated source (regular and test)
25      GENERATED_SOURCE("mvn-cache-ext-generated-source-"),
26      // any unclassified output added by configuration
27      EXTRA_OUTPUT("mvn-cache-ext-extra-output-");
28  
29      private String classifierPrefix;
30  
31      OutputType(String getClassifierPrefix) {
32          this.classifierPrefix = getClassifierPrefix;
33      }
34  
35      public String getClassifierPrefix() {
36          return classifierPrefix;
37      }
38  
39      public static OutputType fromClassifier(String classifier) {
40          if (classifier != null) {
41              if (classifier.startsWith(GENERATED_SOURCE.classifierPrefix)) {
42                  return GENERATED_SOURCE;
43              } else if (classifier.startsWith(EXTRA_OUTPUT.classifierPrefix)) {
44                  return EXTRA_OUTPUT;
45              }
46          }
47          return ARTIFACT;
48      }
49  }