Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-7879] Add a bom packaging #1242

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* 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.
*/
package org.apache.maven.artifact.handler.providers;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Provider;
import javax.inject.Singleton;

import org.apache.maven.artifact.handler.ArtifactHandler;
import org.apache.maven.artifact.handler.DefaultArtifactHandler;

/**
* {@code bom} artifact handler provider.
*/
@Named("bom")
@Singleton
public class BomArtifactHandlerProvider implements Provider<ArtifactHandler> {
private final ArtifactHandler artifactHandler;

@Inject
public BomArtifactHandlerProvider() {
this.artifactHandler = new DefaultArtifactHandler("pom", null, null, null, null, false, "none", false);
}

@Override
public ArtifactHandler get() {
return artifactHandler;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@
@Named("consumer-pom")
public final class ConsumerPomArtifactTransformer {

private static final String BOM_PACKAGING = "bom";

public static final String POM_PACKAGING = "pom";

private static final String CONSUMER_POM_CLASSIFIER = "consumer";

private static final String BUILD_POM_CLASSIFIER = "build";
Expand Down Expand Up @@ -237,6 +241,9 @@ void transform(Path src, Path dest, Model model) {
}

// raw to consumer transform
if (BOM_PACKAGING.equals(consumer.getPackaging())) {
consumer = consumer.withPackaging(POM_PACKAGING);
}
consumer = consumer.withRoot(false).withModules(null);
if (consumer.getParent() != null) {
consumer = consumer.withParent(consumer.getParent().withRelativePath(null));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* 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.
*/
package org.apache.maven.lifecycle.providers.packaging;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

/**
* {@code bom} packaging plugins bindings provider for {@code default} lifecycle.
*/
@Named("bom")
@Singleton
public final class BomLifecycleMappingProvider extends AbstractLifecycleMappingProvider {
// START SNIPPET: bom
@SuppressWarnings("checkstyle:linelength")
private static final String[] BINDINGS = {
"install", "org.apache.maven.plugins:maven-install-plugin:" + INSTALL_PLUGIN_VERSION + ":install",
"deploy", "org.apache.maven.plugins:maven-deploy-plugin:" + DEPLOY_PLUGIN_VERSION + ":deploy"
};
// END SNIPPET: bom

@Inject
public BomLifecycleMappingProvider() {
super(BINDINGS);
}
}