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.plugin.resources.remote.stub;
20  
21  import org.apache.maven.model.Resource;
22  
23  /**
24   * Stub
25   */
26  public class MavenProjectResourcesStub extends MavenProjectBuildStub {
27  
28      public MavenProjectResourcesStub(String id) throws Exception {
29          super(id);
30          setupResources();
31          setupTestResources();
32      }
33  
34      public void addInclude(String pattern) {
35          build.getResources().get(0).addInclude(pattern);
36      }
37  
38      public void addExclude(String pattern) {
39          build.getResources().get(0).addExclude(pattern);
40      }
41  
42      public void addTestInclude(String pattern) {
43          build.getTestResources().get(0).addInclude(pattern);
44      }
45  
46      public void addTestExclude(String pattern) {
47          build.getTestResources().get(0).addExclude(pattern);
48      }
49  
50      public void setTargetPath(String path) {
51          build.getResources().get(0).setTargetPath(path);
52      }
53  
54      public void setTestTargetPath(String path) {
55          build.getTestResources().get(0).setTargetPath(path);
56      }
57  
58      public void setDirectory(String dir) {
59          build.getResources().get(0).setDirectory(dir);
60      }
61  
62      public void setTestDirectory(String dir) {
63          build.getTestResources().get(0).setDirectory(dir);
64      }
65  
66      public void setResourceFiltering(int nIndex, boolean filter) {
67          if (build.getResources().size() > nIndex) {
68              build.getResources().get(nIndex).setFiltering(filter);
69          }
70      }
71  
72      private void setupResources() {
73          Resource resource = new Resource();
74  
75          // see MavenProjectBasicStub for details
76          // of getBasedir
77  
78          // setup default resources
79          resource.setDirectory(getBasedir().getPath() + "/src/main/resources");
80          resource.setFiltering(false);
81          resource.setTargetPath(null);
82          build.addResource(resource);
83      }
84  
85      private void setupTestResources() {
86          Resource resource = new Resource();
87  
88          // see MavenProjectBasicStub for details
89          // of getBasedir
90  
91          // setup default test resources
92          resource.setDirectory(getBasedir().getPath() + "/src/test/resources");
93          resource.setFiltering(false);
94          resource.setTargetPath(null);
95          build.addTestResource(resource);
96      }
97  }