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.repository.internal.type;
20  
21  import javax.inject.Named;
22  
23  import java.util.Arrays;
24  import java.util.Collection;
25  
26  import org.apache.maven.api.JavaPathType;
27  import org.apache.maven.api.Language;
28  import org.apache.maven.api.Type;
29  import org.apache.maven.api.spi.TypeProvider;
30  
31  @Named
32  public class DefaultTypeProvider implements TypeProvider {
33      @SuppressWarnings({"rawtypes", "unchecked"})
34      @Override
35      public Collection<Type> provides() {
36          return (Collection) types();
37      }
38  
39      public Collection<DefaultType> types() {
40          return Arrays.asList(
41                  // Maven types
42                  new DefaultType(Type.POM, Language.NONE, "pom", null, false),
43                  new DefaultType(Type.BOM, Language.NONE, "pom", null, false),
44                  new DefaultType(Type.MAVEN_PLUGIN, Language.JAVA_FAMILY, "jar", null, false, JavaPathType.CLASSES),
45                  // Java types
46                  new DefaultType(
47                          Type.JAR, Language.JAVA_FAMILY, "jar", null, false, JavaPathType.CLASSES, JavaPathType.MODULES),
48                  new DefaultType(Type.JAVADOC, Language.JAVA_FAMILY, "jar", "javadoc", false, JavaPathType.CLASSES),
49                  new DefaultType(Type.JAVA_SOURCE, Language.JAVA_FAMILY, "jar", "sources", false),
50                  new DefaultType(
51                          Type.TEST_JAR,
52                          Language.JAVA_FAMILY,
53                          "jar",
54                          "tests",
55                          false,
56                          JavaPathType.CLASSES,
57                          JavaPathType.PATCH_MODULE),
58                  new DefaultType(Type.MODULAR_JAR, Language.JAVA_FAMILY, "jar", null, false, JavaPathType.MODULES),
59                  new DefaultType(Type.CLASSPATH_JAR, Language.JAVA_FAMILY, "jar", null, false, JavaPathType.CLASSES),
60                  new DefaultType(Type.FATJAR, Language.JAVA_FAMILY, "jar", null, true, JavaPathType.CLASSES),
61                  new DefaultType(
62                          Type.PROCESSOR,
63                          Language.JAVA_FAMILY,
64                          "jar",
65                          null,
66                          false,
67                          JavaPathType.PROCESSOR_CLASSES,
68                          JavaPathType.PROCESSOR_MODULES),
69                  new DefaultType(
70                          Type.MODULAR_PROCESSOR,
71                          Language.JAVA_FAMILY,
72                          "jar",
73                          null,
74                          false,
75                          JavaPathType.PROCESSOR_MODULES),
76                  new DefaultType(
77                          Type.CLASSPATH_PROCESSOR,
78                          Language.JAVA_FAMILY,
79                          "jar",
80                          null,
81                          false,
82                          JavaPathType.PROCESSOR_CLASSES),
83                  // j2ee types
84                  new DefaultType("ejb", Language.JAVA_FAMILY, "jar", null, false, JavaPathType.CLASSES),
85                  new DefaultType("ejb-client", Language.JAVA_FAMILY, "jar", "client", false, JavaPathType.CLASSES),
86                  new DefaultType("war", Language.JAVA_FAMILY, "war", null, true),
87                  new DefaultType("ear", Language.JAVA_FAMILY, "ear", null, true),
88                  new DefaultType("rar", Language.JAVA_FAMILY, "rar", null, true),
89                  new DefaultType("par", Language.JAVA_FAMILY, "par", null, true));
90      }
91  }