View Javadoc
1   package org.apache.felix.bundleplugin;
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 this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this 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 java.io.File;
23  import java.io.IOException;
24  import java.util.LinkedHashSet;
25  import java.util.Set;
26  
27  import org.apache.maven.artifact.Artifact;
28  
29  /**
30   * Fixed version of class that uses stable set ordering for reliable testing.
31   */
32  class ArtifactStubFactory extends org.apache.maven.plugin.testing.ArtifactStubFactory
33  {
34  
35      public ArtifactStubFactory( File workingDir, boolean createFiles )
36      {
37          super( workingDir, createFiles );
38      }
39  
40      @Override
41      public Set<Artifact> getClassifiedArtifacts() throws IOException
42      {
43          Set<Artifact> set = new LinkedHashSet<>();
44          set.add( createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE, "jar", "one" ) );
45          set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE, "jar", "two" ) );
46          set.add( createArtifact( "g", "c", "1.0", Artifact.SCOPE_COMPILE, "jar", "three" ) );
47          set.add( createArtifact( "g", "d", "1.0", Artifact.SCOPE_COMPILE, "jar", "four" ) );
48          return set;
49      }
50  
51      @Override
52      public Set<Artifact> getScopedArtifacts() throws IOException
53      {
54          Set<Artifact> set = new LinkedHashSet<>();
55          set.add( createArtifact( "g", "compile", "1.0", Artifact.SCOPE_COMPILE ) );
56          set.add( createArtifact( "g", "provided", "1.0", Artifact.SCOPE_PROVIDED ) );
57          set.add( createArtifact( "g", "test", "1.0", Artifact.SCOPE_TEST ) );
58          set.add( createArtifact( "g", "runtime", "1.0", Artifact.SCOPE_RUNTIME ) );
59          set.add( createArtifact( "g", "system", "1.0", Artifact.SCOPE_SYSTEM ) );
60          return set;
61      }
62  
63      @Override
64      public Set<Artifact> getTypedArtifacts() throws IOException
65      {
66          Set<Artifact> set = new LinkedHashSet<>();
67          set.add( createArtifact( "g", "a", "1.0", Artifact.SCOPE_COMPILE, "war", null ) );
68          set.add( createArtifact( "g", "b", "1.0", Artifact.SCOPE_COMPILE, "jar", null ) );
69          set.add( createArtifact( "g", "c", "1.0", Artifact.SCOPE_COMPILE, "sources", null ) );
70          set.add( createArtifact( "g", "d", "1.0", Artifact.SCOPE_COMPILE, "zip", null ) );
71          set.add( createArtifact( "g", "e", "1.0", Artifact.SCOPE_COMPILE, "rar", null ) );
72          return set;
73      }
74  
75  }