From e8660d3004829d637baa825ec346bc84949ac1a7 Mon Sep 17 00:00:00 2001 From: Sebastian Baumhekel Date: Tue, 3 Nov 2015 10:37:34 +0100 Subject: [PATCH] Allow using a module name without a package name. Remove ensureTrailingSlash call as the slash is already there (it is actually used for splitting the path). A module name without a package part results in a super directory created at the target/classes directory. Fixes this error for a module named "gwt-util": [ERROR] Failed to execute goal net.ltgt.gwt.maven:gwt-maven-plugin:1.0-rc-3:add-super-sources (add-super-sources) on project gwt-util: Execution add-super-sources of goal net.ltgt.gwt.maven:gwt-maven-plugin:1.0-rc-3:add-super-sources failed: String index out of range: -1 -> [Help 1] --- .../ltgt/gwt/maven/AbstractAddSuperSourcesMojo.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/ltgt/gwt/maven/AbstractAddSuperSourcesMojo.java b/src/main/java/net/ltgt/gwt/maven/AbstractAddSuperSourcesMojo.java index 60ea82f3..18b4855c 100644 --- a/src/main/java/net/ltgt/gwt/maven/AbstractAddSuperSourcesMojo.java +++ b/src/main/java/net/ltgt/gwt/maven/AbstractAddSuperSourcesMojo.java @@ -29,10 +29,15 @@ public void execute() throws MojoExecutionException { throw new MojoExecutionException("Cannot relocate super-sources if moduleName is not specified"); } String targetPath = moduleName.replace('.', '/'); - // Keep only package name - targetPath = targetPath.substring(0, targetPath.lastIndexOf('/')); + // Keep only package name (if there is one) + int lastTrailingSlash = targetPath.lastIndexOf('/'); + if (lastTrailingSlash > 0) { + targetPath = targetPath.substring(0, lastTrailingSlash + 1); + } else { + targetPath = ""; + } // Relocate into 'super' subfolder - targetPath = ensureTrailingSlash(targetPath) + "super/"; + targetPath += "super/"; resource.setTargetPath(targetPath); } addResource(resource);