You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by cs...@apache.org on 2021/09/23 09:14:17 UTC

[maven] 01/01: Convert maven-core components XML to Providers

This is an automated email from the ASF dual-hosted git repository.

cstamas pushed a commit to branch drop-components-xml
in repository https://gitbox.apache.org/repos/asf/maven.git

commit 4cb8909336a5d7eb17e4e444bc9deeffa80426ba
Author: Tamas Cservenak <ta...@cservenak.net>
AuthorDate: Thu Sep 23 11:13:46 2021 +0200

    Convert maven-core components XML to Providers
    
    This change get's rid of component.xml in maven-core
---
 .../providers/CleanLifecycleProvider.java          |  61 ++++++++
 .../providers/DefaultLifecycleProvider.java        |  76 ++++++++++
 .../lifecycle/providers/SiteLifecycleProvider.java |  64 +++++++++
 .../providers/WrapperLifecycleProvider.java        |  59 ++++++++
 .../main/resources/META-INF/plexus/components.xml  | 154 ---------------------
 .../crypto/MavenSecDispatcherProvider.java         |  56 ++++++++
 6 files changed, 316 insertions(+), 154 deletions(-)

diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/providers/CleanLifecycleProvider.java b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/CleanLifecycleProvider.java
new file mode 100644
index 0000000..17b0d79
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/CleanLifecycleProvider.java
@@ -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;
+  }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/providers/DefaultLifecycleProvider.java b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/DefaultLifecycleProvider.java
new file mode 100644
index 0000000..6039e80
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/DefaultLifecycleProvider.java
@@ -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;
+  }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/providers/SiteLifecycleProvider.java b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/SiteLifecycleProvider.java
new file mode 100644
index 0000000..68980ab
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/SiteLifecycleProvider.java
@@ -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;
+  }
+}
diff --git a/maven-core/src/main/java/org/apache/maven/lifecycle/providers/WrapperLifecycleProvider.java b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/WrapperLifecycleProvider.java
new file mode 100644
index 0000000..d951f74
--- /dev/null
+++ b/maven-core/src/main/java/org/apache/maven/lifecycle/providers/WrapperLifecycleProvider.java
@@ -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;
+  }
+}
diff --git a/maven-core/src/main/resources/META-INF/plexus/components.xml b/maven-core/src/main/resources/META-INF/plexus/components.xml
deleted file mode 100644
index bd2aa6c..0000000
--- a/maven-core/src/main/resources/META-INF/plexus/components.xml
+++ /dev/null
@@ -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>
diff --git a/maven-settings-builder/src/main/java/org/apache/maven/settings/crypto/MavenSecDispatcherProvider.java b/maven-settings-builder/src/main/java/org/apache/maven/settings/crypto/MavenSecDispatcherProvider.java
new file mode 100644
index 0000000..e59d7e0
--- /dev/null
+++ b/maven-settings-builder/src/main/java/org/apache/maven/settings/crypto/MavenSecDispatcherProvider.java
@@ -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;
+    }
+}