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