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
SHRINKWRAP-505 - Allow addPackage() to be smarter about .war files #99
Conversation
This commit brings about the smartness required for URLPackageScanner to understand that a URL that represents a .war has its classes relocated under WEB-INF/lib instead of from the root of the archive. Part of the change is pre-constructing the Asset passed to the scanner's Callback, taking into account the location of the underlying asset, separate from it's actual related class name.
* @return new instance of URLPackageScanner | ||
*/ | ||
public static URLPackageScanner newInstance(boolean addRecursively, ClassLoader classLoader, Callback callback) { | ||
public static URLPackageScanner newInstance(boolean addRecursively, ClassLoader classLoader, Callback callback) throws IOException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
throws IOE, but we catch it and swallow? Need to throw here in the method declar? Would prefer not if we're just going to swallow it or wrap in RuntimeException.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. Can remove from signature. Will do tomorrow. I realized we can swallow and not propagate but forgot to remove from the method.
Sent from my iPhone
On May 31, 2016, at 5:29 PM, Andrew Lee Rubinger notifications@github.com wrote:
In impl-base/src/main/java/org/jboss/shrinkwrap/impl/base/URLPackageScanner.java:
* @return new instance of URLPackageScanner */
- public static URLPackageScanner newInstance(boolean addRecursively, ClassLoader classLoader, Callback callback) {
- public static URLPackageScanner newInstance(boolean addRecursively, ClassLoader classLoader, Callback callback) throws IOException {
throws IOE, but we catch it and swallow? Need to throw here in the method declar? Would prefer not if we're just going to swallow it or wrap in RuntimeException.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
@ALRubinger -- So reasoning for the change... People can have a war project in maven, but with WildFly Swarm still provide a main(). In which case, they also want to programaticly assemble an archive for deployment into Swarm. We do magic so that the current classloader running main() can see everything in the .war. We actually load it into the current classpath. But, if You might think we could then Hence the tracking if the 'prefix' in the scanner, to help determine where to search, and what to remove from the class name ( I had to amend the Callback because simply knowing class The pattern we actually see, in WildFly Swarm, is
and I'd hoped the Package object passed in would have some connection to Main.class's classloader, but that appears not to be the case. Within SW, everything becomes a String before any real work is accomplished. |
This commit brings about the smartness required for URLPackageScanner
to understand that a URL that represents a .war has its classes
relocated under WEB-INF/lib instead of from the root of the archive.
Part of the change is pre-constructing the Asset passed to the
scanner's Callback, taking into account the location of the underlying
asset, separate from it's actual related class name.