Convert maven-core components XML to Providers

This change get's rid of component.xml in maven-core
This commit is contained in:
Tamas Cservenak 2021-09-23 11:13:46 +02:00
parent f50de4ce9e
commit 4cb8909336
6 changed files with 316 additions and 154 deletions

View File

@ -0,0 +1,61 @@
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 javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import javax.inject.Singleton;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.maven.lifecycle.Lifecycle;
import org.apache.maven.lifecycle.mapping.LifecyclePhase;
@Named( "clean" )
@Singleton
public final class CleanLifecycleProvider
implements Provider<Lifecycle>
{
private final Lifecycle lifecycle;
@Inject
public CleanLifecycleProvider()
{
this.lifecycle = new Lifecycle(
"clean",
ImmutableList.of(
"pre-clean",
"clean",
"post-clean"
),
ImmutableMap.of(
"clean",
new LifecyclePhase( "org.apache.maven.plugins:maven-clean-plugin:3.1.0:clean" )
)
);
}
@Override
public Lifecycle get()
{
return lifecycle;
}
}

View File

@ -0,0 +1,76 @@
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 javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import javax.inject.Singleton;
import com.google.common.collect.ImmutableList;
import org.apache.maven.lifecycle.Lifecycle;
@Named( "default" )
@Singleton
public final class DefaultLifecycleProvider
implements Provider<Lifecycle>
{
private final Lifecycle lifecycle;
@Inject
public DefaultLifecycleProvider()
{
this.lifecycle = new Lifecycle(
"default",
ImmutableList.of(
"validate",
"initialize",
"generate-sources",
"process-sources",
"generate-resources",
"process-resources",
"compile",
"process-classes",
"generate-test-sources",
"process-test-sources",
"generate-test-resources",
"process-test-resources",
"test-compile",
"process-test-classes",
"test",
"prepare-package",
"package",
"pre-integration-test",
"integration-test",
"post-integration-test",
"verify",
"install",
"deploy"
),
null
);
}
@Override
public Lifecycle get()
{
return lifecycle;
}
}

View File

@ -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 javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import javax.inject.Singleton;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.maven.lifecycle.Lifecycle;
import org.apache.maven.lifecycle.mapping.LifecyclePhase;
@Named( "site" )
@Singleton
public final class SiteLifecycleProvider
implements Provider<Lifecycle>
{
private final Lifecycle lifecycle;
@Inject
public SiteLifecycleProvider()
{
this.lifecycle = new Lifecycle(
"site",
ImmutableList.of(
"pre-site",
"site",
"post-site",
"site-deploy"
),
ImmutableMap.of(
"site",
new LifecyclePhase( "org.apache.maven.plugins:maven-site-plugin:3.9.1:site" ),
"site-deploy",
new LifecyclePhase( "org.apache.maven.plugins:maven-site-plugin:3.9.1:deploy" )
)
);
}
@Override
public Lifecycle get()
{
return lifecycle;
}
}

View File

@ -0,0 +1,59 @@
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 javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import javax.inject.Singleton;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import org.apache.maven.lifecycle.Lifecycle;
import org.apache.maven.lifecycle.mapping.LifecyclePhase;
@Named( "wrapper" )
@Singleton
public final class WrapperLifecycleProvider
implements Provider<Lifecycle>
{
private final Lifecycle lifecycle;
@Inject
public WrapperLifecycleProvider()
{
this.lifecycle = new Lifecycle(
"wrapper",
ImmutableList.of(
"wrapper"
),
ImmutableMap.of(
"wrapper",
new LifecyclePhase( "org.apache.maven.plugins:maven-wrapper-plugin:3.0.2:wrapper" )
)
);
}
@Override
public Lifecycle get()
{
return lifecycle;
}
}

View File

@ -1,154 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<!--
There is currently only one component descriptor that cannot be generated from annotations because of the
accompanying configuration. Our options are to embed this information programatically or use a configuration source
to pull in the lifecycle information.
-->
<component-set>
<components>
<!-- 'default' lifecycle, without any binding since it is dependent on packaging -->
<component>
<role>org.apache.maven.lifecycle.Lifecycle</role>
<implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
<role-hint>default</role-hint>
<configuration>
<id>default</id>
<!-- START SNIPPET: lifecycle -->
<phases>
<phase>validate</phase>
<phase>initialize</phase>
<phase>generate-sources</phase>
<phase>process-sources</phase>
<phase>generate-resources</phase>
<phase>process-resources</phase>
<phase>compile</phase>
<phase>process-classes</phase>
<phase>generate-test-sources</phase>
<phase>process-test-sources</phase>
<phase>generate-test-resources</phase>
<phase>process-test-resources</phase>
<phase>test-compile</phase>
<phase>process-test-classes</phase>
<phase>test</phase>
<phase>prepare-package</phase>
<phase>package</phase>
<phase>pre-integration-test</phase>
<phase>integration-test</phase>
<phase>post-integration-test</phase>
<phase>verify</phase>
<phase>install</phase>
<phase>deploy</phase>
</phases>
<!-- END SNIPPET: lifecycle -->
</configuration>
</component>
<!-- 'clean' lifecycle, with default binding -->
<component>
<role>org.apache.maven.lifecycle.Lifecycle</role>
<implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
<role-hint>clean</role-hint>
<configuration>
<id>clean</id>
<!-- START SNIPPET: clean -->
<phases>
<phase>pre-clean</phase>
<phase>clean</phase>
<phase>post-clean</phase>
</phases>
<default-phases>
<clean>
org.apache.maven.plugins:maven-clean-plugin:3.1.0:clean
</clean>
</default-phases>
<!-- END SNIPPET: clean -->
</configuration>
</component>
<!-- 'site' lifecycle, with default bindings -->
<component>
<role>org.apache.maven.lifecycle.Lifecycle</role>
<implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
<role-hint>site</role-hint>
<configuration>
<id>site</id>
<!-- START SNIPPET: site -->
<phases>
<phase>pre-site</phase>
<phase>site</phase>
<phase>post-site</phase>
<phase>site-deploy</phase>
</phases>
<default-phases>
<site>
org.apache.maven.plugins:maven-site-plugin:3.9.1:site
</site>
<site-deploy>
org.apache.maven.plugins:maven-site-plugin:3.9.1:deploy
</site-deploy>
</default-phases>
<!-- END SNIPPET: site -->
</configuration>
</component>
<!-- 'wrapper' lifecycle, with default bindings -->
<component>
<role>org.apache.maven.lifecycle.Lifecycle</role>
<implementation>org.apache.maven.lifecycle.Lifecycle</implementation>
<role-hint>wrapper</role-hint>
<configuration>
<id>wrapper</id>
<!-- START SNIPPET: wrapper -->
<phases>
<phase>wrapper</phase>
</phases>
<default-phases>
<wrapper>
org.apache.maven.plugins:maven-wrapper-plugin:3.0.2:wrapper
</wrapper>
</default-phases>
<!-- END SNIPPET: wrapper -->
</configuration>
</component>
<component>
<role>org.sonatype.plexus.components.sec.dispatcher.SecDispatcher</role>
<role-hint>maven</role-hint>
<implementation>org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher</implementation>
<description>Maven Security dispatcher</description>
<requirements>
<requirement>
<role>org.sonatype.plexus.components.cipher.PlexusCipher</role>
<field-name>_cipher</field-name>
</requirement>
<requirement>
<role>org.sonatype.plexus.components.sec.dispatcher.PasswordDecryptor</role>
<field-name>_decryptors</field-name>
</requirement>
</requirements>
<configuration>
<_configuration-file>~/.m2/settings-security.xml</_configuration-file>
</configuration>
</component>
</components>
</component-set>

View File

@ -0,0 +1,56 @@
package org.apache.maven.settings.crypto;
/*
* 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.Map;
import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import javax.inject.Singleton;
import org.sonatype.plexus.components.cipher.DefaultPlexusCipher;
import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher;
import org.sonatype.plexus.components.sec.dispatcher.PasswordDecryptor;
import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher;
@Named( "maven" )
@Singleton
public final class MavenSecDispatcherProvider
implements Provider<SecDispatcher>
{
private final SecDispatcher secDispatcher;
@Inject
public MavenSecDispatcherProvider( final Map<String, PasswordDecryptor> decryptors )
{
this.secDispatcher = new DefaultSecDispatcher(
new DefaultPlexusCipher(),
decryptors,
"~/.m2/settings-security.xml"
);
}
@Override
public SecDispatcher get()
{
return secDispatcher;
}
}