View Javadoc

1   package org.apache.maven.lifecycle;
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.plugin.MojoExecution;
23  
24  /**
25   * @since 3.0
26   * @author Kristian Rosenvold
27   */
28  @SuppressWarnings( { "UnusedDeclaration" } )
29  public class Schedule
30  {
31      private String phase;
32  
33      private String upstreamPhase; // The upstream phase to lock to.
34  
35      private String pluginKey;
36  
37      private String mojoGoal;
38  
39      private boolean mojoSynchronized;
40      // Indicates that this phase/mojo does not need to respect the reactor-dependency graph
41      // (Module lifecycle order still must be respected )
42  
43      private boolean parallel;
44  
45      public Schedule()
46      {
47      }
48  
49      public Schedule( String phase, boolean mojoSynchronized, boolean parallel )
50      {
51          this.phase = phase;
52          this.mojoSynchronized = mojoSynchronized;
53          this.parallel = parallel;
54      }
55  
56  
57      public String getPhase()
58      {
59          return phase;
60      }
61  
62      public void setPhase( String phase )
63      {
64          this.phase = phase;
65      }
66  
67      public String getPluginKey()
68      {
69          return pluginKey;
70      }
71  
72      public void setPluginKey( String pluginKey )
73      {
74          this.pluginKey = pluginKey;
75      }
76  
77      public boolean isMojoSynchronized()
78      {
79          return mojoSynchronized;
80      }
81  
82      public void setMojoSynchronized( boolean mojoSynchronized )
83      {
84          this.mojoSynchronized = mojoSynchronized;
85      }
86  
87  
88      public boolean isParallel()
89      {
90          return parallel;
91      }
92  
93      public void setParallel( boolean parallel )
94      {
95          this.parallel = parallel;
96      }
97  
98      public String getUpstreamPhase()
99      {
100         return upstreamPhase;
101     }
102 
103     public void setUpstreamPhase( String upstreamPhase )
104     {
105         this.upstreamPhase = upstreamPhase;
106     }
107 
108     public String getMojoGoal()
109     {
110         return mojoGoal;
111     }
112 
113     public void setMojoGoal( String mojoGoal )
114     {
115         this.mojoGoal = mojoGoal;
116     }
117 
118     public boolean hasUpstreamPhaseDefined()
119     {
120         return getUpstreamPhase() != null;
121     }
122 
123     public boolean appliesTo( MojoExecution mojoExecution )
124     {
125         boolean pluginKeyMatches = true;
126         boolean pluginGoalMatches = true;
127         if ( pluginKey == null && mojoGoal == null )
128         {
129             return false;
130         }
131         if ( pluginKey != null )
132         {
133             pluginKeyMatches = pluginKey.equals( mojoExecution.getPlugin().getKey() );
134         }
135         if ( mojoGoal != null )
136         {
137             pluginGoalMatches = mojoGoal.equals( mojoExecution.getGoal() );
138         }
139 
140         if ( pluginKeyMatches && pluginGoalMatches )
141         {
142             return true;
143         }
144         return false;
145     }
146 
147     @Override
148     public String toString()
149     {
150         return "Schedule{" + "phase='" + phase + '\'' + ", upstreamPhase='" + upstreamPhase + '\'' + ", pluginKey='"
151             + pluginKey + '\'' + ", mojoGoal='" + mojoGoal + '\'' + ", mojoSynchronized=" + mojoSynchronized
152             + ", parallel=" + parallel + '}';
153     }
154 }