Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes a number of errors in the bndrun handling #6401

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,9 @@ public Bndrun init(File runFile, String task, File workingDir) throws Exception
run.setParent(getProcessor(workspace));
run.clear();
run.forceRefresh(); // setBase must be called after forceRefresh
run.setBase(temporaryDir);
// this should imho not be there, it should
// be the parent directory of the properties file, as it was.
// run.setBase(temporaryDir);
run.getInfo(workspace);
setRunrequiresFromProjectArtifact(run);
setEEfromBuild(run);
Expand Down
88 changes: 88 additions & 0 deletions biz.aQute.bndlib.tests/test/test/BndEditModelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@

import java.io.ByteArrayInputStream;
import java.io.File;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.junit.jupiter.api.Test;
import org.osgi.framework.namespace.IdentityNamespace;
Expand Down Expand Up @@ -255,6 +257,92 @@ public void testGetPropertiesWithOnlyWorkspace() throws Exception {
assertThat(p.getProperty("foo")).isEqualTo("FOO");
}

/**
* Test the testresources/bndtools-resolve-reproducer project (m2). There
* were issues with the inheritance and inclusion of properties.
*/

static final File REPRODUCER = IO.getFile("testresources/bndtools-resolve-reproducer");
static final File DEBUG_BNDRUN = IO.getFile(REPRODUCER, "debug.bndrun");
static final Map<String, String> PROPERTIES = Map.of("-runbundles",
"org.apache.felix.gogo.command;version='[1.1.2,1.1.3)',org.apache.felix.gogo.runtime;version='[1.1.6,1.1.7)',org.apache.felix.gogo.shell;version='[1.1.4,1.1.5)'", //
"-resolve.effective", "active", //
"-runfw", "org.eclipse.osgi;version='3.21.0'", //
"-runproperties.debug", "osgi.console=,osgi.console.enable.builtin=false", //
"-runrequires", "bnd.identity;id='org.example.bndtools.bndrun.reproducer'", //
"-runee", "JavaSE-17", //
"-runrequires.debug",
"osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.runtime)',osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)'" //

);

@Test
public void testBasicReproducer() throws Exception {
assertThat(DEBUG_BNDRUN).isFile();
Run run = Run.createRun(null, DEBUG_BNDRUN);
assertThat(run.getProperties()).containsExactlyInAnyOrderEntriesOf(PROPERTIES);
BndEditModel model = new BndEditModel(run);

assertThat(model.getAllPropertyNames()).containsExactlyInAnyOrder("-runbundles", "-runrequires.debug",
"-runproperties.debug", "-include");

}

@Test
public void testBasicReproducerRemove() throws Exception {
assertThat(DEBUG_BNDRUN).isFile();
Run run = Run.createRun(null, DEBUG_BNDRUN);
BndEditModel model = new BndEditModel(run);

assertThat(model.getProperties()
.getProperties()).containsKey("-runbundles");
assertThat(model.getDocumentChanges()).isEmpty();
assertThat(model.getDocumentProperties()
.keySet()).containsExactlyInAnyOrder("-runbundles", "-runrequires.debug", "-runproperties.debug",
"-include");

model.setRunBundles(Collections.emptyList());

assertThat(model.getRunBundles()).isEmpty();
assertThat(model.getDocumentChanges()).containsKey("-runbundles");
assertThat(model.getProperties()
.getProperties()).doesNotContainKey("-runbundles");

Document d = new Document(IO.collect(DEBUG_BNDRUN));
assertThat(d.get()).contains("-runbundles");

model.saveChangesTo(d);

assertThat(model.getDocumentChanges()).isEmpty();
assertThat(d.get()).doesNotContain("-runbundles");
assertThat(model.getDocumentProperties()
.keySet()).containsExactlyInAnyOrder("-runrequires.debug", "-runproperties.debug", "-include");
}

@Test
public void testBasicReproducerAdd() throws Exception {
assertThat(DEBUG_BNDRUN).isFile();
Run run = Run.createRun(null, DEBUG_BNDRUN);
BndEditModel model = new BndEditModel(run);

assertThat(model.getProperties()
.getProperties()).doesNotContainKey("-runframework");

model.setRunFramework("none");

assertThat(model.getDocumentProperties()).doesNotContainKey("-runframework");

assertThat(model.getProperties()
.getProperties()).containsKey("-runframework");

assertThat(model.getRunFramework()).isEqualTo("none");
Document d = new Document(IO.collect(DEBUG_BNDRUN));
assertThat(d.get()).doesNotContain("-runframework");
model.saveChangesTo(d);
assertThat(model.getDocumentChanges()).isEmpty();
assertThat(d.get()).contains("-runframework");
}

private String getPortablePath(File base) {
String path = base.getAbsolutePath();
if (File.separatorChar != '/') {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.

In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

For more information, please refer to <https://unlicense.org/>.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#Bundle-Activator: org.example.bndtools.bndrun.reproducer.Activator
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
-include: ~run.bndrun
-standalone: target/index.xml
-resolve.effective: active
-runfw: org.eclipse.osgi;version='3.21.0'
-runee: JavaSE-17
-runproperties.debug: \
osgi.console=,\
osgi.console.enable.builtin=false
-runrequires.debug: \
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.shell)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.runtime)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)'
-runbundles: \
org.apache.felix.gogo.command;version='[1.1.2,1.1.3)',\
org.apache.felix.gogo.runtime;version='[1.1.6,1.1.7)',\
org.apache.felix.gogo.shell;version='[1.1.4,1.1.5)',\
org.example.bndtools.bndrun.reproducer;version='[1.0.0,1.0.1)'
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-include: ~run.bndrun
-runproperties.debug: \
osgi.console=,\
osgi.console.enable.builtin=false
-runrequires.debug: \
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.runtime)',\
osgi.identity;filter:='(osgi.identity=org.apache.felix.gogo.command)'
-runbundles: \
org.apache.felix.gogo.command;version='[1.1.2,1.1.3)',\
org.apache.felix.gogo.runtime;version='[1.1.6,1.1.7)',\
org.apache.felix.gogo.shell;version='[1.1.4,1.1.5)'
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>org.example.bndtools.bndrun.reproducer</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<bnd.version>7.1.0</bnd.version>
</properties>
<dependencies>
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<version>3.21.0</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.gogo.shell</artifactId>
<version>1.1.4</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.gogo.runtime</artifactId>
<version>1.1.6</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.gogo.command</artifactId>
<version>1.1.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<version>${bnd.version}</version>
<executions>
<execution>
<goals>
<goal>bnd-process</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.4.2</version>
<configuration>
<archive>
<manifestFile>
${project.build.outputDirectory}/META-INF/MANIFEST.MF
</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-indexer-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<includeJar>true</includeJar>
<localURLs>REQUIRED</localURLs>
<attach>false</attach>
</configuration>
<executions>
<execution>
<goals>
<goal>index</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-resolver-maven-plugin</artifactId>
<version>${bnd.version}</version>
<configuration>
<failOnChanges>false</failOnChanges>
<bndruns>
<bndrun>run.bndrun</bndrun>
<bndrun>debug.bndrun</bndrun>
<bndrun>debug-standalone.bndrun</bndrun>
</bndruns>
</configuration>
<executions>
<execution>
<id>resolve</id>
<goals>
<goal>resolve</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-export-maven-plugin</artifactId>
<version>${bnd.version}</version>
<executions>
<execution>
<goals>
<goal>export</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-resolve.effective: active
-runfw: org.eclipse.osgi;version='3.21.0'
-runee: JavaSE-17
-runrequires: bnd.identity;id='org.example.bndtools.bndrun.reproducer'
-runbundles: org.example.bndtools.bndrun.reproducer;version='[1.0.0,1.0.1)'
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.example.bndtools.bndrun.reproducer;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;

public class Activator{
}
Loading
Loading