View Javadoc

1   package org.apache.maven.lifecycle.internal;
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.lifecycle.Schedule;
23  import org.apache.maven.model.Plugin;
24  import org.apache.maven.plugin.MojoExecution;
25  import org.apache.maven.plugin.descriptor.MojoDescriptor;
26  
27  import java.util.concurrent.CountDownLatch;
28  
29  /**
30   * Wraps individual MojoExecutions, containing information about completion status and scheduling.
31   * <p/>
32   * NOTE: This class is not part of any public api and can be changed or deleted without prior notice.
33   * 
34   * @since 3.0
35   * @author Kristian Rosenvold
36   */
37  public class ExecutionPlanItem
38  {
39      private final MojoExecution mojoExecution;
40  
41      private final Schedule schedule;
42      // Completeness just indicates that it has been run or failed
43  
44      private final CountDownLatch done = new CountDownLatch( 1 );
45  
46      public ExecutionPlanItem( MojoExecution mojoExecution, Schedule schedule )
47      {
48          this.mojoExecution = mojoExecution;
49          this.schedule = schedule;
50      }
51  
52      public MojoExecution getMojoExecution()
53      {
54          return mojoExecution;
55      }
56  
57      public String getLifecyclePhase()
58      {
59          return mojoExecution.getLifecyclePhase();
60      }
61  
62      public void setComplete()
63      {
64          done.countDown();
65      }
66  
67      public boolean isDone()
68      {
69          return done.getCount() < 1;
70      }
71  
72      public void forceComplete()
73      {
74          setComplete();
75      }
76  
77      public void waitUntilDone()
78          throws InterruptedException
79      {
80          done.await();
81      }
82  
83      public Schedule getSchedule()
84      {
85          return schedule;
86      }
87  
88      public Plugin getPlugin()
89      {
90          final MojoDescriptor mojoDescriptor = getMojoExecution().getMojoDescriptor();
91          return mojoDescriptor.getPluginDescriptor().getPlugin();
92      }
93  
94      @Override
95      public String toString()
96      {
97          return "ExecutionPlanItem{" + ", mojoExecution=" + mojoExecution + ", schedule=" + schedule + '}'
98              + super.toString();
99      }
100 
101 }