-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Tycho SBOM mapper configurable w.r.t. the project packaging types
Instead of being applied on all packaging types (even those where it doesn't make sense like the target platform), the user is now able to configure for which project types the Tycho model converter is used. By default (if nothing else is specified), this converter is only used for plugins and features, to avoid issues when the e.g. the target definition is defined in its own module or the the reactor contains non-Tycho packaging types (jar/pom/bundle/...). (cherry picked from commit e972652)
- Loading branch information
1 parent
03cb31d
commit 900f0c6
Showing
10 changed files
with
181 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: Test-Fragment with SBOM | ||
Bundle-SymbolicName: example.test1 | ||
Bundle-Version: 1.0.0.qualifier | ||
Fragment-Host: example.plugin | ||
Automatic-Module-Name: example.test1 | ||
Bundle-RequiredExecutionEnvironment: JavaSE-17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pom.model.packaging = eclipse-test-plugin | ||
source.. = src/ | ||
output.. = bin/ | ||
bin.includes = META-INF/,\ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: Test-Fragment with SBOM | ||
Bundle-SymbolicName: example.test2 | ||
Bundle-Version: 1.0.0.qualifier | ||
Fragment-Host: example.plugin | ||
Automatic-Module-Name: example.test2 | ||
Bundle-RequiredExecutionEnvironment: JavaSE-17 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pom.model.packaging = eclipse-test-plugin | ||
source.. = src/ | ||
output.. = bin/ | ||
bin.includes = META-INF/,\ | ||
. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
tycho-sbom/src/main/java/org/eclipse/tycho/sbom/TychoSBOMConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Patrick Ziegler and others. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Patrick Ziegler - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.tycho.sbom; | ||
|
||
import java.util.Arrays; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import org.apache.maven.model.Plugin; | ||
import org.apache.maven.project.MavenProject; | ||
import org.codehaus.plexus.util.xml.Xpp3Dom; | ||
import org.eclipse.tycho.PackagingType; | ||
|
||
/** | ||
* Configuration of the {@code tycho-sbom} plugin to configure the packaging | ||
* types for which the {@link TychoModelConverter} is used. By default only | ||
* plug-ins and features are supported, but user may include additional types | ||
* using this class. Example: | ||
* | ||
* <pre> | ||
* <configuration> | ||
* <includes> | ||
* <include>eclipse-plugin</include> | ||
* <include>eclipse-feature</include> | ||
* <include>eclipse-repository</include> | ||
* </includes> | ||
* </configuration>> | ||
* </pre> | ||
*/ | ||
public class TychoSBOMConfiguration { | ||
private static final Set<String> DEFAULT_TYPES = Set.of(PackagingType.TYPE_ECLIPSE_FEATURE, | ||
PackagingType.TYPE_ECLIPSE_PLUGIN); | ||
private static final String KEY_INCLUDES = "includes"; | ||
/** | ||
* Contains all packaging types for which the {@link TychoModelConverter} should | ||
* be used. Initialized with {@link #DEFAULT_TYPES} if no other configuration is | ||
* specified. | ||
*/ | ||
private Set<String> includes = DEFAULT_TYPES; | ||
|
||
/** | ||
* A default implementation that is used when used outside of a Maven project. | ||
*/ | ||
public TychoSBOMConfiguration() { | ||
// no-op | ||
} | ||
|
||
/** | ||
* Initializes the configuration based on the configuration of the | ||
* {@code tycho-sbom} plugin. If no configuration exists, this configuration is | ||
* initialized with its default values. | ||
*/ | ||
public TychoSBOMConfiguration(MavenProject currentProject) { | ||
Plugin plugin = currentProject.getPlugin("org.eclipse.tycho:tycho-sbom"); | ||
if (plugin != null && plugin.getConfiguration() instanceof Xpp3Dom root) { | ||
readIncludes(root.getChild(KEY_INCLUDES)); | ||
} | ||
} | ||
|
||
private void readIncludes(Xpp3Dom parent) { | ||
if (parent == null) { | ||
return; | ||
} | ||
// Overwrite default configuration | ||
includes = Arrays.stream(parent.getChildren()) // | ||
.map(Xpp3Dom::getValue) // | ||
.collect(Collectors.toUnmodifiableSet()); | ||
} | ||
|
||
/** | ||
* Returns all packaging types for which the {@link TychoModelConverter} should | ||
* be used. | ||
* | ||
* @return An unmodifiable list of {@link String}s. | ||
*/ | ||
public Set<String> getIncludedPackagingTypes() { | ||
// Set is already immutable | ||
return includes; | ||
} | ||
} |