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.internal.impl.resolver.type;
20  
21  import java.util.Arrays;
22  import java.util.Collection;
23  
24  import org.apache.maven.api.JavaPathType;
25  import org.apache.maven.api.Language;
26  import org.apache.maven.api.Type;
27  import org.apache.maven.api.di.Named;
28  import org.apache.maven.api.spi.TypeProvider;
29  
30  @Named
31  public class DefaultTypeProvider implements TypeProvider {
32      @SuppressWarnings({"rawtypes", "unchecked"})
33      @Override
34      public Collection<Type> provides() {
35          return (Collection) types();
36      }
37  
38      public Collection<DefaultType> types() {
39          return Arrays.asList(
40                  // Maven types
41                  new DefaultType(Type.POM, Language.NONE, "pom", null, false),
42                  new DefaultType(Type.BOM, Language.NONE, "pom", null, false),
43                  new DefaultType(Type.MAVEN_PLUGIN, Language.JAVA_FAMILY, "jar", null, false, JavaPathType.CLASSES),
44                  // Java types
45                  new DefaultType(
46                          Type.JAR, Language.JAVA_FAMILY, "jar", null, false, JavaPathType.CLASSES, JavaPathType.MODULES),
47                  new DefaultType(Type.JAVADOC, Language.JAVA_FAMILY, "jar", "javadoc", false, JavaPathType.CLASSES),
48                  new DefaultType(Type.JAVA_SOURCE, Language.JAVA_FAMILY, "jar", "sources", false),
49                  new DefaultType(
50                          Type.TEST_JAR,
51                          Language.JAVA_FAMILY,
52                          "jar",
53                          "tests",
54                          false,
55                          JavaPathType.CLASSES,
56                          JavaPathType.PATCH_MODULE),
57                  new DefaultType(Type.MODULAR_JAR, Language.JAVA_FAMILY, "jar", null, false, JavaPathType.MODULES),
58                  new DefaultType(Type.CLASSPATH_JAR, Language.JAVA_FAMILY, "jar", null, false, JavaPathType.CLASSES),
59                  // j2ee types
60                  new DefaultType("ejb", Language.JAVA_FAMILY, "jar", null, false, JavaPathType.CLASSES),
61                  new DefaultType("ejb-client", Language.JAVA_FAMILY, "jar", "client", false, JavaPathType.CLASSES),
62                  new DefaultType("war", Language.JAVA_FAMILY, "war", null, true),
63                  new DefaultType("ear", Language.JAVA_FAMILY, "ear", null, true),
64                  new DefaultType("rar", Language.JAVA_FAMILY, "rar", null, true),
65                  new DefaultType("par", Language.JAVA_FAMILY, "par", null, true));
66      }
67  }