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