Skip to content

Commit

Permalink
reficio#241: add default bnd instruction for supporting multi-release
Browse files Browse the repository at this point in the history
  • Loading branch information
sparsick committed Apr 2, 2021
1 parent d0d221e commit 2d18fd8
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
Expand All @@ -30,6 +31,15 @@
*/
public final class ArtifactBundlerInstructions {

/**
* BND instructions that should be used when no instruction is set.
*/
private static Map<String, String> DEFAULT_INSTRUCTIONS = new LinkedHashMap<>();

static {
DEFAULT_INSTRUCTIONS.put("_fixupmessages", "\"Classes found in the wrong directory\";is:=warning");
}

private final String name;
private final String symbolicName;
private final String symbolicNameWithOptions;
Expand All @@ -51,7 +61,11 @@ private ArtifactBundlerInstructions(String name, String symbolicName, String sym
this.sourceName = sourceName;
this.sourceSymbolicName = sourceSymbolicName;
this.proposedVersion = proposedVersion;
this.instructions = instructions;
if(instructions.isEmpty()) {
this.instructions = DEFAULT_INSTRUCTIONS;
} else {
this.instructions = instructions;
}
this.snapshot = snapshot;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Copyright (c) 2012 Reficio (TM) - Reestablish your software! All Rights Reserved.
*
* 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.reficio.p2.bundler;

import org.junit.Test;

import java.util.Collections;

import static org.assertj.core.api.Assertions.assertThat;


public class ArtifactBundlerInstructionsTest {

@Test
public void useDefaultInstruction(){
ArtifactBundlerInstructions artifactBundlerInstructions = ArtifactBundlerInstructions.builder().build();

assertThat(artifactBundlerInstructions.getInstructions())
.hasSize(1)
.containsEntry("_fixupmessages", "\"Classes found in the wrong directory\";is:=warning");

}

@Test
public void ignoreDefaultInstruction(){
ArtifactBundlerInstructions artifactBundlerInstructions = ArtifactBundlerInstructions.builder()
.instructions(Collections.singletonMap("-noee", "true"))
.build();

assertThat(artifactBundlerInstructions.getInstructions())
.hasSize(1)
.containsEntry("-noee", "true");
}

}

0 comments on commit 2d18fd8

Please sign in to comment.