Skip to content

Commit

Permalink
Merge pull request #6057 from pkriens/feature/5959-error-on-multiple-…
Browse files Browse the repository at this point in the history
…files-for-singletons

Warning on bin, testsrc, testbin, target properties to be single file…
  • Loading branch information
pkriens authored Mar 18, 2024
2 parents fae66b0 + bb0297a commit 70ac0f0
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions biz.aQute.bndlib/src/aQute/bnd/build/Project.java
Original file line number Diff line number Diff line change
Expand Up @@ -498,19 +498,19 @@ public File getSrc() throws Exception {
}

public File getSrcOutput() {
return getFile(getProperty(Constants.DEFAULT_PROP_BIN_DIR));
return getSingleFile(Constants.DEFAULT_PROP_BIN_DIR);
}

public File getTestSrc() {
return getFile(getProperty(Constants.DEFAULT_PROP_TESTSRC_DIR));
return getSingleFile(Constants.DEFAULT_PROP_TESTSRC_DIR);
}

public File getTestOutput() {
return getFile(getProperty(Constants.DEFAULT_PROP_TESTBIN_DIR));
return getSingleFile(Constants.DEFAULT_PROP_TESTBIN_DIR);
}

public File getTargetDir() {
return getFile(getProperty(Constants.DEFAULT_PROP_TARGET_DIR));
return getSingleFile(Constants.DEFAULT_PROP_TARGET_DIR);
}

private void traverse(Set<Project> dependencies, Project dependent, Set<Project> visited) throws Exception {
Expand All @@ -524,6 +524,17 @@ private void traverse(Set<Project> dependencies, Project dependent, Set<Project>
dependents.add(dependent);
}

private File getSingleFile(String key) {
String value = getProperty(key);
if (value == null) {
error("project.%s expected value for property %s but got null", key, key);
value = key;
} else if (value.indexOf(',') >= 0) {
error("project.%s expected one file path for property %s but got multiple: %s", key, key, value);
}
return getFile(value);
}

/**
* Iterate over the entries and place the projects on the projects list and
* all the files of the entries on the resultpath.
Expand Down Expand Up @@ -1921,8 +1932,7 @@ public File[] buildLocal(boolean underTest) throws Exception {
if (lastModified < jar.lastModified()) {
lastModified = jar.lastModified();
}
Supplier<org.osgi.resource.Resource> indexer = ResourceBuilder.memoize(jar,
file.toURI(),
Supplier<org.osgi.resource.Resource> indexer = ResourceBuilder.memoize(jar, file.toURI(),
getName());
if (indexer != null) {
resourceBuilders.add(indexer);
Expand Down Expand Up @@ -1987,7 +1997,6 @@ public File[] buildLocal(boolean underTest) throws Exception {
}
}


boolean bfsWrite = !bfs.exists() || (lastModified > bfs.lastModified());
if (buildfiles != null) {
Set<File> removed = Create.set(buildfiles);
Expand Down

0 comments on commit 70ac0f0

Please sign in to comment.