You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2021/09/23 11:28:53 UTC

[GitHub] [maven] slawekjaranowski commented on a change in pull request #550: Convert maven-core default-bindings to Providers

slawekjaranowski commented on a change in pull request #550:
URL: https://github.com/apache/maven/pull/550#discussion_r714702777



##########
File path: maven-core/src/main/java/org/apache/maven/lifecycle/mapping/LifecycleMappingImpl.java
##########
@@ -0,0 +1,62 @@
+package org.apache.maven.lifecycle.mapping;
+
+/*
+ * 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.Collections;
+import java.util.List;
+import java.util.Map;
+
+import static java.util.stream.Collectors.toMap;
+
+/**
+ * Alternate implementation of {@link LifecycleMapping} as default one is too much plexus-suited.
+ */
+public final class LifecycleMappingImpl
+    implements LifecycleMapping
+{
+  private final Map<String, Lifecycle> lifecycles;
+
+  public LifecycleMappingImpl( final List<Lifecycle> lifecycles )
+  {
+    this.lifecycles = Collections.unmodifiableMap(
+        lifecycles.stream().collect( toMap( Lifecycle::getId, l -> l ) )
+    );
+  }
+
+  @Override
+  public Map<String, Lifecycle> getLifecycles()
+  {
+    return lifecycles;
+  }
+
+  @Deprecated

Review comment:
       as usual why is deprecated ...
   
   maybe if it must stay in interface use default  methods .. so child class will needn't implement it

##########
File path: maven-core/src/main/java/org/apache/maven/lifecycle/mapping/providers/EarLifecycleMappingProvider.java
##########
@@ -0,0 +1,83 @@
+package org.apache.maven.lifecycle.mapping.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.Collections;
+import java.util.HashMap;
+
+import javax.inject.Inject;
+import javax.inject.Named;
+import javax.inject.Provider;
+import javax.inject.Singleton;
+
+import org.apache.maven.lifecycle.mapping.Lifecycle;
+import org.apache.maven.lifecycle.mapping.LifecycleMapping;
+import org.apache.maven.lifecycle.mapping.LifecycleMappingImpl;
+import org.apache.maven.lifecycle.mapping.LifecyclePhase;
+
+@Named( "ear" )
+@Singleton
+public final class EarLifecycleMappingProvider
+    implements Provider<LifecycleMapping>
+{
+  private final LifecycleMapping lifecycleMapping;
+
+  @Inject
+  public EarLifecycleMappingProvider()
+  {
+    HashMap<String, LifecyclePhase> lifecyclePhases = new HashMap<>();
+    lifecyclePhases.put(
+        "generate-resources",

Review comment:
       Can such labels be defined as constant or even enums?
   or it is too early for such refactor ...




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org