Skip to content

Commit

Permalink
* Add classOrPackageNames parameter to CacheMojo (pull #510)
Browse files Browse the repository at this point in the history
  • Loading branch information
HGuillemet committed Aug 6, 2021
1 parent 8bb5735 commit 5d56bc6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

* Add `classOrPackageNames` parameter to `CacheMojo` ([pull #510](https://github.com/bytedeco/javacpp/pull/510))

### August 2, 2021 version 1.5.6
* Add missing export to `module-info.java` file for presets package ([pull #508](https://github.com/bytedeco/javacpp/pull/508))
* Add `@NoException(true)` value to support overriding `virtual noexcept` functions
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/bytedeco/javacpp/tools/BuildMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ public class BuildMojo extends AbstractMojo {
@Parameter(defaultValue = "${plugin}", required = true, readonly = true)
PluginDescriptor plugin;

String[] merge(String[] ss, String s) {
static String[] merge(String[] ss, String s) {
if (ss != null && s != null) {
ss = Arrays.copyOf(ss, ss.length + 1);
ss[ss.length - 1] = s;
Expand Down
19 changes: 17 additions & 2 deletions src/main/java/org/bytedeco/javacpp/tools/CacheMojo.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2019 Samuel Audet
* Copyright (C) 2019-2021 Samuel Audet
*
* Licensed either under the Apache License, Version 2.0, or (at your option)
* under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -53,6 +53,15 @@
@Mojo(name = "cache", defaultPhase = LifecyclePhase.NONE, threadSafe = true,
requiresDependencyResolution = ResolutionScope.COMPILE_PLUS_RUNTIME)
public class CacheMojo extends AbstractMojo {

/** Process only this class or package (suffixed with .* or .**). */
@Parameter(property = "javacpp.classOrPackageName")
String classOrPackageName = null;

/** Process only these classes or packages (suffixed with .* or .**). */
@Parameter(property = "javacpp.classOrPackageNames")
String[] classOrPackageNames = null;

@Parameter(defaultValue = "${project}", required = true, readonly = true)
MavenProject project;

Expand Down Expand Up @@ -103,7 +112,13 @@ String join(String separator, Iterable<String> strings) {
for (Artifact a : artifacts) {
classLoader.addPaths(a.getFile().getAbsolutePath());
}
classScanner.addPackage(null, true);

classOrPackageNames = BuildMojo.merge(classOrPackageNames, classOrPackageName);
if (classOrPackageNames == null || classOrPackageNames.length == 0) {
classScanner.addPackage(null, true);
} else for (String s : classOrPackageNames) {
classScanner.addClassOrPackage(s);
}

LinkedHashSet<String> packages = new LinkedHashSet<String>();
for (Class c : classes) {
Expand Down

0 comments on commit 5d56bc6

Please sign in to comment.