001package org.apache.maven.lifecycle;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 *  http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import org.apache.maven.plugin.MojoExecution;
023
024/**
025 * @since 3.0
026 * @author Kristian Rosenvold
027 */
028public class Schedule
029{
030    private String phase;
031
032    private String upstreamPhase; // The upstream phase to lock to.
033
034    private String pluginKey;
035
036    private String mojoGoal;
037
038    private boolean mojoSynchronized;
039    // Indicates that this phase/mojo does not need to respect the reactor-dependency graph
040    // (Module lifecycle order still must be respected )
041
042    private boolean parallel;
043
044    public Schedule()
045    {
046    }
047
048    public Schedule( String phase, boolean mojoSynchronized, boolean parallel )
049    {
050        this.phase = phase;
051        this.mojoSynchronized = mojoSynchronized;
052        this.parallel = parallel;
053    }
054
055
056    public String getPhase()
057    {
058        return phase;
059    }
060
061    public void setPhase( String phase )
062    {
063        this.phase = phase;
064    }
065
066    public String getPluginKey()
067    {
068        return pluginKey;
069    }
070
071    public void setPluginKey( String pluginKey )
072    {
073        this.pluginKey = pluginKey;
074    }
075
076    public boolean isMojoSynchronized()
077    {
078        return mojoSynchronized;
079    }
080
081    public void setMojoSynchronized( boolean mojoSynchronized )
082    {
083        this.mojoSynchronized = mojoSynchronized;
084    }
085
086
087    public boolean isParallel()
088    {
089        return parallel;
090    }
091
092    public void setParallel( boolean parallel )
093    {
094        this.parallel = parallel;
095    }
096
097    public String getUpstreamPhase()
098    {
099        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}