Skip to content

Commit

Permalink
Merge pull request #5696 from pkriens/issue/change_naming_extra_file_…
Browse files Browse the repository at this point in the history
…maven

Use classifier instead of 'class' and archive instead of 'extra'
  • Loading branch information
pkriens committed Jun 12, 2023
2 parents 69585b0 + 874ff41 commit 14eb03a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
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 @@ -489,12 +489,12 @@ private ReleaseDTO getReleaseDTO(Processor context) {
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++);
.getOrDefault(Constants.MAVEN_RELEASE_CLASSIFIER, "classifier-" + clazz++);
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 @@ -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 14eb03a

Please sign in to comment.