mirror of https://github.com/apache/maven.git
[MNG-7263] introduce AbstractLifecycleProvider
This commit is contained in:
parent
e5b0831c10
commit
711d5fbbf2
|
@ -0,0 +1,64 @@
|
||||||
|
package org.apache.maven.lifecycle.providers;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import javax.inject.Provider;
|
||||||
|
|
||||||
|
import org.apache.maven.lifecycle.Lifecycle;
|
||||||
|
import org.apache.maven.lifecycle.mapping.LifecyclePhase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base lifecycle provider.
|
||||||
|
*/
|
||||||
|
public abstract class AbstractLifecycleProvider
|
||||||
|
implements Provider<Lifecycle>
|
||||||
|
{
|
||||||
|
private final Lifecycle lifecycle;
|
||||||
|
|
||||||
|
protected AbstractLifecycleProvider( String id, String[] phases, String[] pluginBindings )
|
||||||
|
{
|
||||||
|
HashMap<String, LifecyclePhase> defaultBindings = null;
|
||||||
|
if ( pluginBindings != null )
|
||||||
|
{
|
||||||
|
int len = pluginBindings.length;
|
||||||
|
defaultBindings = new HashMap<>();
|
||||||
|
for ( int i = 0; i < len; i++ )
|
||||||
|
{
|
||||||
|
defaultBindings.put( pluginBindings[i++], new LifecyclePhase( pluginBindings[i] ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.lifecycle = new Lifecycle(
|
||||||
|
id,
|
||||||
|
Collections.unmodifiableList( Arrays.asList( phases ) ),
|
||||||
|
defaultBindings == null ? null : Collections.unmodifiableMap( defaultBindings )
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Lifecycle get()
|
||||||
|
{
|
||||||
|
return lifecycle;
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,52 +19,33 @@ package org.apache.maven.lifecycle.providers;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Provider;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.apache.maven.lifecycle.Lifecycle;
|
|
||||||
import org.apache.maven.lifecycle.mapping.LifecyclePhase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code clean} lifecycle provider.
|
* {@code clean} lifecycle provider.
|
||||||
*/
|
*/
|
||||||
@Named( "clean" )
|
@Named( "clean" )
|
||||||
@Singleton
|
@Singleton
|
||||||
public final class CleanLifecycleProvider
|
public final class CleanLifecycleProvider
|
||||||
implements Provider<Lifecycle>
|
extends AbstractLifecycleProvider
|
||||||
{
|
{
|
||||||
private static final String LIFECYCLE_ID = "clean";
|
private static final String LIFECYCLE_ID = "clean";
|
||||||
|
|
||||||
private static final String[] PHASES = {
|
private static final String[] PHASES = {
|
||||||
"pre-clean",
|
"pre-clean",
|
||||||
"clean",
|
"clean",
|
||||||
"post-clean"
|
"post-clean"
|
||||||
};
|
};
|
||||||
|
|
||||||
private final Lifecycle lifecycle;
|
private static final String[] BINDINGS = {
|
||||||
|
"clean", "org.apache.maven.plugins:maven-clean-plugin:3.1.0:clean"
|
||||||
|
};
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public CleanLifecycleProvider()
|
public CleanLifecycleProvider()
|
||||||
{
|
{
|
||||||
HashMap<String, LifecyclePhase> defaultBindings = new HashMap<>();
|
super( LIFECYCLE_ID, PHASES, BINDINGS );
|
||||||
defaultBindings.put( "clean", new LifecyclePhase( "org.apache.maven.plugins:maven-clean-plugin:3.1.0:clean" ) );
|
}
|
||||||
|
|
||||||
this.lifecycle = new Lifecycle(
|
|
||||||
LIFECYCLE_ID,
|
|
||||||
Collections.unmodifiableList( Arrays.asList( PHASES ) ),
|
|
||||||
Collections.unmodifiableMap( defaultBindings )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Lifecycle get()
|
|
||||||
{
|
|
||||||
return lifecycle;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,67 +19,51 @@ package org.apache.maven.lifecycle.providers;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Provider;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.apache.maven.lifecycle.Lifecycle;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code default} lifecycle provider.
|
* {@code default} lifecycle provider.
|
||||||
*/
|
*/
|
||||||
@Named( "default" )
|
@Named( "default" )
|
||||||
@Singleton
|
@Singleton
|
||||||
public final class DefaultLifecycleProvider
|
public final class DefaultLifecycleProvider
|
||||||
implements Provider<Lifecycle>
|
extends AbstractLifecycleProvider
|
||||||
{
|
{
|
||||||
private static final String LIFECYCLE_ID = "default";
|
private static final String LIFECYCLE_ID = "default";
|
||||||
|
|
||||||
private static final String[] PHASES = {
|
private static final String[] PHASES = {
|
||||||
"validate",
|
"validate",
|
||||||
"initialize",
|
"initialize",
|
||||||
"generate-sources",
|
"generate-sources",
|
||||||
"process-sources",
|
"process-sources",
|
||||||
"generate-resources",
|
"generate-resources",
|
||||||
"process-resources",
|
"process-resources",
|
||||||
"compile",
|
"compile",
|
||||||
"process-classes",
|
"process-classes",
|
||||||
"generate-test-sources",
|
"generate-test-sources",
|
||||||
"process-test-sources",
|
"process-test-sources",
|
||||||
"generate-test-resources",
|
"generate-test-resources",
|
||||||
"process-test-resources",
|
"process-test-resources",
|
||||||
"test-compile",
|
"test-compile",
|
||||||
"process-test-classes",
|
"process-test-classes",
|
||||||
"test",
|
"test",
|
||||||
"prepare-package",
|
"prepare-package",
|
||||||
"package",
|
"package",
|
||||||
"pre-integration-test",
|
"pre-integration-test",
|
||||||
"integration-test",
|
"integration-test",
|
||||||
"post-integration-test",
|
"post-integration-test",
|
||||||
"verify",
|
"verify",
|
||||||
"install",
|
"install",
|
||||||
"deploy"
|
"deploy"
|
||||||
};
|
};
|
||||||
|
|
||||||
private final Lifecycle lifecycle;
|
@Inject
|
||||||
|
public DefaultLifecycleProvider()
|
||||||
@Inject
|
{
|
||||||
public DefaultLifecycleProvider()
|
super( LIFECYCLE_ID, PHASES,
|
||||||
{
|
null // no global plugin bindings for default lifecycle: they are defined per-packaging in separate providers
|
||||||
this.lifecycle = new Lifecycle(
|
);
|
||||||
LIFECYCLE_ID,
|
}
|
||||||
Collections.unmodifiableList( Arrays.asList( PHASES ) ),
|
|
||||||
null // no global plugin bindings for default lifecycle: they are defined per-packaging in separate providers
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Lifecycle get()
|
|
||||||
{
|
|
||||||
return lifecycle;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,54 +19,35 @@ package org.apache.maven.lifecycle.providers;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Provider;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.apache.maven.lifecycle.Lifecycle;
|
|
||||||
import org.apache.maven.lifecycle.mapping.LifecyclePhase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code site} lifecycle provider.
|
* {@code site} lifecycle provider.
|
||||||
*/
|
*/
|
||||||
@Named( "site" )
|
@Named( "site" )
|
||||||
@Singleton
|
@Singleton
|
||||||
public final class SiteLifecycleProvider
|
public final class SiteLifecycleProvider
|
||||||
implements Provider<Lifecycle>
|
extends AbstractLifecycleProvider
|
||||||
{
|
{
|
||||||
private static final String LIFECYCLE_ID = "site";
|
private static final String LIFECYCLE_ID = "site";
|
||||||
|
|
||||||
private static final String[] PHASES = {
|
private static final String[] PHASES = {
|
||||||
"pre-site",
|
"pre-site",
|
||||||
"site",
|
"site",
|
||||||
"post-site",
|
"post-site",
|
||||||
"site-deploy"
|
"site-deploy"
|
||||||
};
|
};
|
||||||
|
|
||||||
private final Lifecycle lifecycle;
|
private static final String[] BINDINGS = {
|
||||||
|
"site", "org.apache.maven.plugins:maven-site-plugin:3.9.1:site",
|
||||||
|
"site-deploy", "org.apache.maven.plugins:maven-site-plugin:3.9.1:deploy"
|
||||||
|
};
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SiteLifecycleProvider()
|
public SiteLifecycleProvider()
|
||||||
{
|
{
|
||||||
HashMap<String, LifecyclePhase> defaultBindings = new HashMap<>();
|
super( LIFECYCLE_ID, PHASES, BINDINGS );
|
||||||
defaultBindings.put( "site", new LifecyclePhase( "org.apache.maven.plugins:maven-site-plugin:3.9.1:site" ) );
|
}
|
||||||
defaultBindings.put( "site-deploy", new LifecyclePhase( "org.apache.maven.plugins:maven-site-plugin:3.9.1:deploy" ) );
|
|
||||||
|
|
||||||
this.lifecycle = new Lifecycle(
|
|
||||||
LIFECYCLE_ID,
|
|
||||||
Collections.unmodifiableList( Arrays.asList( PHASES ) ),
|
|
||||||
Collections.unmodifiableMap( defaultBindings )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Lifecycle get()
|
|
||||||
{
|
|
||||||
return lifecycle;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,51 +19,32 @@ package org.apache.maven.lifecycle.providers;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Named;
|
import javax.inject.Named;
|
||||||
import javax.inject.Provider;
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.apache.maven.lifecycle.Lifecycle;
|
|
||||||
import org.apache.maven.lifecycle.mapping.LifecyclePhase;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@code wrapper} lifecycle provider.
|
* {@code wrapper} lifecycle provider.
|
||||||
*/
|
*/
|
||||||
@Named( "wrapper" )
|
@Named( "wrapper" )
|
||||||
@Singleton
|
@Singleton
|
||||||
public final class WrapperLifecycleProvider
|
public final class WrapperLifecycleProvider
|
||||||
implements Provider<Lifecycle>
|
extends AbstractLifecycleProvider
|
||||||
{
|
{
|
||||||
private static final String LIFECYCLE_ID = "wrapper";
|
private static final String LIFECYCLE_ID = "wrapper";
|
||||||
|
|
||||||
private static final String[] PHASES =
|
private static final String[] PHASES =
|
||||||
{
|
{
|
||||||
"wrapper"
|
"wrapper"
|
||||||
};
|
};
|
||||||
|
|
||||||
private final Lifecycle lifecycle;
|
private static final String[] BINDINGS = {
|
||||||
|
"wrapper", "org.apache.maven.plugins:maven-wrapper-plugin:3.1.0:wrapper"
|
||||||
|
};
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public WrapperLifecycleProvider()
|
public WrapperLifecycleProvider()
|
||||||
{
|
{
|
||||||
HashMap<String, LifecyclePhase> defaultBindings = new HashMap<>();
|
super( LIFECYCLE_ID, PHASES, BINDINGS );
|
||||||
defaultBindings.put( "wrapper", new LifecyclePhase( "org.apache.maven.plugins:maven-wrapper-plugin:3.1.0:wrapper" ) );
|
}
|
||||||
|
|
||||||
this.lifecycle = new Lifecycle(
|
|
||||||
LIFECYCLE_ID,
|
|
||||||
Collections.unmodifiableList( Arrays.asList( PHASES ) ),
|
|
||||||
Collections.unmodifiableMap( defaultBindings )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Lifecycle get()
|
|
||||||
{
|
|
||||||
return lifecycle;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue