From 874ff41382982eaefb2f725a1103f4f8ab37befb Mon Sep 17 00:00:00 2001 From: Peter Kriens Date: Mon, 12 Jun 2023 12:02:50 +0200 Subject: [PATCH] Use classifier instead of 'class' and archive instead of 'extra' --- Signed-off-by: Peter Kriens Signed-off-by: Peter Kriens --- biz.aQute.bndlib/src/aQute/bnd/osgi/Constants.java | 3 +++ .../maven/provider/MavenBndRepository.java | 9 +++++---- .../maven/provider/MavenBndRepoTest.java | 13 ++++++++----- docs/_instructions/maven-release.md | 14 +++++++------- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/biz.aQute.bndlib/src/aQute/bnd/osgi/Constants.java b/biz.aQute.bndlib/src/aQute/bnd/osgi/Constants.java index 5f08899410..1f16d305ad 100644 --- a/biz.aQute.bndlib/src/aQute/bnd/osgi/Constants.java +++ b/biz.aQute.bndlib/src/aQute/bnd/osgi/Constants.java @@ -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"; diff --git a/biz.aQute.repository/src/aQute/bnd/repository/maven/provider/MavenBndRepository.java b/biz.aQute.repository/src/aQute/bnd/repository/maven/provider/MavenBndRepository.java index 4cfffb2e8c..13fe742ad9 100644 --- a/biz.aQute.repository/src/aQute/bnd/repository/maven/provider/MavenBndRepository.java +++ b/biz.aQute.repository/src/aQute/bnd/repository/maven/provider/MavenBndRepository.java @@ -489,12 +489,12 @@ private ReleaseDTO getReleaseDTO(Processor context) { Entry 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++); + .getOrDefault(Constants.MAVEN_RELEASE_CLASSIFIER, "classifier-" + clazz++); String path = e.getValue() - .get("path"); + .get(Constants.MAVEN_RELEASE_PATH); boolean preprocess = false; @@ -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; } diff --git a/biz.aQute.repository/test/aQute/bnd/repository/maven/provider/MavenBndRepoTest.java b/biz.aQute.repository/test/aQute/bnd/repository/maven/provider/MavenBndRepoTest.java index 274ceb5d7f..6e0fbaed22 100644 --- a/biz.aQute.repository/test/aQute/bnd/repository/maven/provider/MavenBndRepoTest.java +++ b/biz.aQute.repository/test/aQute/bnd/repository/maven/provider/MavenBndRepoTest.java @@ -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(); @@ -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"); @@ -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(); @@ -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); } diff --git a/docs/_instructions/maven-release.md b/docs/_instructions/maven-release.md index 96d8568b5e..d8606fb598 100644 --- a/docs/_instructions/maven-release.md +++ b/docs/_instructions/maven-release.md @@ -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 ::= 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' ) )? @@ -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