Skip to content

Commit

Permalink
Rename class to classifier in the -maven-release extra function to be…
Browse files Browse the repository at this point in the history
… consistent with Archive

---

Signed-off-by: Peter Kriens <Peter.Kriens@aQute.biz>
  • Loading branch information
pkriens committed Jun 12, 2023
1 parent d31e205 commit 3cffaa4
Show file tree
Hide file tree
Showing 6 changed files with 134 additions and 21 deletions.
106 changes: 106 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: "CI Build"

on:
push:
branches-ignore:
- "dependabot/**"
paths:
- "**"
- "!docs/**"
- "!.github/**"
- ".github/**/*ci*"
pull_request:
paths:
- "**"
- "!docs/**"
- "!.github/**"
- ".github/**/*ci*"

env:
LC_ALL: en_US.UTF-8
GRADLE_OPTS: >-
-Dorg.gradle.parallel=true
MAVEN_OPTS: >-
-Dhttp.keepAlive=false
-Dmaven.wagon.http.pool=false
-Dmaven.wagon.http.retryHandler.count=3
defaults:
run:
shell: bash

permissions:
contents: read

jobs:
build:
strategy:
fail-fast: ${{ (github.repository != 'bndtools/bnd') || ((github.ref != 'refs/heads/master') && (github.ref != 'refs/heads/next')) || (github.event_name == 'pull_request') }}
matrix:
os:
- "ubuntu-latest"
java:
- "8"
- "11"
- "18"
runner:
- "xvfb-run --auto-servernum {0}"
include:
- os: "ubuntu-latest"
java: "17"
runner: "xvfb-run --auto-servernum {0}"
canonical: ${{ (github.repository == 'bndtools/bnd') && ((github.ref == 'refs/heads/classic') || (github.ref == 'refs/heads/master') || (github.ref == 'refs/heads/next')) && (github.event_name != 'pull_request') }}
fetch-depth: "0"
- os: "windows-latest"
java: "17"
runner: "{0}"
name: Build JDK${{ matrix.java }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
steps:
- name: Harden Runner
uses: step-security/harden-runner@ebacdc22ef6c2cfb85ee5ded8f2e640f4c776dd5
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

- name: Git Checkout
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
with:
fetch-depth: ${{ matrix.fetch-depth }}
- name: Set up Java ${{ matrix.java }}
uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc
with:
distribution: "temurin"
java-version: ${{ matrix.java }}
- name: Set up Gradle
uses: gradle/gradle-build-action@3fbe033aaae657f011f88f29be9e65ed26bd29ef
- name: Build
id: build
run: |
${{ format(matrix.runner, './.github/scripts/ci-build.sh') }}
- name: Configure settings.xml for Publish
if: ${{ matrix.canonical }}
uses: actions/setup-java@de1bb2b0c5634f0fc4438d7aa9944e68f9bf86cc
with:
distribution: "temurin"
java-version: ${{ matrix.java }}
server-id: bndtools.jfrog.io
server-username: JFROG_USERNAME
server-password: JFROG_PASSWORD
- name: Publish
id: publish
if: ${{ matrix.canonical }}
run: |
./.github/scripts/ci-publish.sh
env:
CANONICAL: ${{ matrix.canonical }}
JFROG_USERNAME: ${{ secrets.JFROG_USERNAME }}
JFROG_PASSWORD: ${{ secrets.JFROG_PASSWORD }}
- name: Upload Test Reports
if: ${{ always() && ((steps.build.outcome == 'success') || (steps.build.outcome == 'failure')) }}
uses: actions/upload-artifact@83fd05a356d7e2593de66fc9913b3002723633cb
with:
name: Build_JDK${{ matrix.java }}_${{ matrix.os }}-test-reports
path: |
*/generated/test-reports/*/TEST-*.xml
maven/*/target/surefire-reports/TEST-*.xml
gradle-plugins/*/build/test-results/*/TEST-*.xml
3 changes: 3 additions & 0 deletions biz.aQute.bndlib/src/aQute/bnd/osgi/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ public interface Constants {
String METATYPE_ANNOTATIONS_OPTIONS = "-metatypeannotations-options";
String MANIFEST = "-manifest";
String MAVEN_RELEASE = "-maven-release";
String MAVEN_RELEASE_CLASSIFIER = "classifier";
String MAVEN_RELEASE_ARCHIVE = "archive";
String MAVEN_RELEASE_PATH = "path";
String MAVEN_DEPENDENCIES = "-maven-dependencies";
String MAVEN_SCOPE = "-maven-scope";
String PROFILE = "-profile";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private void doExtra(PutOptions options, ReleaseDTO instructions, IPom pom, Rele
String path = extra.path;
String parts[] = Strings.extension(path);
String ext = parts == null ? ".unknown" : parts[1];
String clazz = extra.clazz;
String clazz = extra.classifier;
File file = new File(path);
if (!file.isFile())
reporter.error("-release-maven.extra contains a path to a file that does not exist: %s",
Expand Down Expand Up @@ -440,7 +440,7 @@ private ReleaseDTO getReleaseDTO(Processor context) {

Attrs javadoc = p.remove("javadoc");
if (javadoc != null) {
release.javadoc.path = javadoc.remove("path");
release.javadoc.path = javadoc.remove(Constants.MAVEN_RELEASE_PATH);
release.javadoc.force = Boolean.parseBoolean(javadoc.remove("force"));
if (NONE.equals(release.javadoc.path)) {
release.javadoc = null;
Expand Down Expand Up @@ -481,20 +481,20 @@ private ReleaseDTO getReleaseDTO(Processor context) {
}


int clazz = 0;
int classifier = 0;

for (Iterator<Entry<String, Attrs>> it = p.entrySet()
.iterator(); it.hasNext();) {

Entry<String, Attrs> e = it.next();
String key = Processor.removeDuplicateMarker(e.getKey());
switch (key) {
case "extra" -> {
case Constants.MAVEN_RELEASE_ARCHIVE -> {
ExtraDTO extra = new ExtraDTO();
extra.clazz = e.getValue()
.getOrDefault("class", "class-" + clazz++);
extra.classifier = e.getValue()
.getOrDefault(Constants.MAVEN_RELEASE_CLASSIFIER, "classifier-" + classifier++);
String path = e.getValue()
.get("path");
.get(Constants.MAVEN_RELEASE_PATH);

boolean preprocess = false;

Expand All @@ -507,7 +507,8 @@ private ReleaseDTO getReleaseDTO(Processor context) {
path = context.getFile(path)
.getAbsolutePath();
} else {
reporter.warning("The -maven-release instruction has an extra without the path attribute: %s",
reporter.warning(
"The -maven-release instruction has an 'archive' without the path attribute: %s",
e);
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static class SourceDTO extends DTO {

public static class ExtraDTO extends DTO {
public String path;
public String clazz;
public String classifier;
public boolean preprocess;
public Map<String, String> options = new HashMap<>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,8 @@ public void testPutMavenExtraFiles() throws Exception {
try (Processor context = new Processor()) {
context.setProperty("test", "1234");
context.setProperty("-maven-release",
"extra;path=testresources/extra/test.foo,extra;path={testresources/extra/test.bar};class=BAR");
"archive;path=testresources/extra/test.foo,"
+ "archive;path={testresources/extra/test.bar};classifier=BAR");

File jar = IO.getFile("testresources/release-nosource.jar");
PutOptions options = new PutOptions();
Expand All @@ -396,7 +397,8 @@ public void testPutMavenExtraFiles() throws Exception {
assertThat(context.check()).isTrue();

assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0/biz.aQute.bnd.maven-3.2.0.jar", 89400);
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0/biz.aQute.bnd.maven-3.2.0-class-0.foo", 16);
assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0/biz.aQute.bnd.maven-3.2.0-classifier-0.foo",
16);
String content = IO
.collect(new File(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0/biz.aQute.bnd.maven-3.2.0-BAR.bar"));
assertThat(content).contains("this is test bar with 1234 x");
Expand All @@ -410,7 +412,7 @@ public void testPutMavenExtraNoFile() throws Exception {
.toString());
config(map);
try (Processor context = new Processor()) {
context.setProperty("-maven-release", "extra;path=i_do_not_exist");
context.setProperty("-maven-release", "archive;path=i_do_not_exist");

File jar = IO.getFile("testresources/release-nosource.jar");
PutOptions options = new PutOptions();
Expand All @@ -430,14 +432,15 @@ public void testPutMavenExtraNoPath() throws Exception {
.toString());
config(map);
try (Processor context = new Processor()) {
context.setProperty("-maven-release", "extra");
context.setProperty("-maven-release", "archive");

File jar = IO.getFile("testresources/release-nosource.jar");
PutOptions options = new PutOptions();
options.context = context;
PutResult put = repo.put(new FileInputStream(jar), options);
context.getInfo(repo.reporter);
assertThat(context.check("No metadata for revision", "has an extra without the path attribute")).isTrue();
assertThat(context.check("No metadata for revision", "has an 'archive' without the path attribute"))
.isTrue();

assertIsFile(remote, "biz/aQute/bnd/biz.aQute.bnd.maven/3.2.0/biz.aQute.bnd.maven-3.2.0.jar", 89400);
}
Expand Down
14 changes: 7 additions & 7 deletions docs/_instructions/maven-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ Though this instruction is not specific for a plugin, it was developed in conjun
-maven-release ::= ( 'local'|'remote' ( ';' snapshot )? ) ( ',' option )*
snapshot ::= <value to be used for timestamp>
option ::= sources | javadoc | pom | sign | extra*
extra ::= 'extra'
archive ::= 'archive'
( ';path=' ( PATH | '{' PATH '}' )?
( ';class=' maven-class )?
( ';classifier=' maven-classifier )?
sources ::= 'sources'
( ';path=' ( 'NONE' | PATH ) )?
( ';force=' ( 'true' | 'false' ) )?
Expand Down Expand Up @@ -45,19 +45,19 @@ The repository has the following parameters:

If the Maven Bnd Repository is asked to put a file, it will look up the `-maven-release` instruction using merged properties. The property is looked up from the bnd file that built the artifact. However, it should in general be possible to define this header in the workspace using macros like `${project}` to specify relative paths.

The `extra` option provides a way to add additional files to release. A Maven release always has a pom and then a number of files that are separated by a _class_. The default class is generally the jar file. Special classes are reserved for the sources and the javadoc.
The `archive` option provides a way to add additional files/archives to release. A Maven release always has a pom and then a number of files/archives that are separated by a _classifier_. The default classifier is generally the jar file. Special classifiers are reserved for the sources and the javadoc.

The `extra` option takes the following parameters:
The `archive` option takes the following parameters:

* `path` : The path to the file that will be placed in the release directory. If the path is surrounded by curly braces, it will be pre-processed.
* `class` : The class of the file. This is the maven class used.
* `classifier` : The classifier of the file. This is the maven classifier used.

For example:

-maven-release \
extra;\
archive;\
path=files/feature.json;
class=feature
classifier=feature
# Signing

Expand Down

0 comments on commit 3cffaa4

Please sign in to comment.