return packageName;
}
protected Package makePackage( final Project project,
final Path resource ) {
final Path projectRoot = project.getRootPath();
final org.uberfire.java.nio.file.Path nioProjectRoot = Paths.convert( projectRoot );
final org.uberfire.java.nio.file.Path nioMainSrcPath = nioProjectRoot.resolve( MAIN_SRC_PATH );
final org.uberfire.java.nio.file.Path nioTestSrcPath = nioProjectRoot.resolve( TEST_SRC_PATH );
final org.uberfire.java.nio.file.Path nioMainResourcesPath = nioProjectRoot.resolve( MAIN_RESOURCES_PATH );
final org.uberfire.java.nio.file.Path nioTestResourcesPath = nioProjectRoot.resolve( TEST_RESOURCES_PATH );
org.uberfire.java.nio.file.Path nioResource = Paths.convert( resource );
if ( Files.isRegularFile( nioResource ) ) {
nioResource = nioResource.getParent();
}
String packageName = null;
org.uberfire.java.nio.file.Path packagePath = null;
if ( nioResource.startsWith( nioMainSrcPath ) ) {
packagePath = nioMainSrcPath.relativize( nioResource );
packageName = packagePath.toString().replaceAll( "/",
"." );
} else if ( nioResource.startsWith( nioTestSrcPath ) ) {
packagePath = nioTestSrcPath.relativize( nioResource );
packageName = packagePath.toString().replaceAll( "/",
"." );
} else if ( nioResource.startsWith( nioMainResourcesPath ) ) {
packagePath = nioMainResourcesPath.relativize( nioResource );
packageName = packagePath.toString().replaceAll( "/",
"." );
} else if ( nioResource.startsWith( nioTestResourcesPath ) ) {
packagePath = nioTestResourcesPath.relativize( nioResource );
packageName = packagePath.toString().replaceAll( "/",
"." );
}
//Resource was not inside a package
if ( packageName == null ) {
return null;
}
final Path mainSrcPath = Paths.convert( nioMainSrcPath.resolve( packagePath ) );
final Path testSrcPath = Paths.convert( nioTestSrcPath.resolve( packagePath ) );
final Path mainResourcesPath = Paths.convert( nioMainResourcesPath.resolve( packagePath ) );
final Path testResourcesPath = Paths.convert( nioTestResourcesPath.resolve( packagePath ) );
final String displayName = getPackageDisplayName( packageName );
final Package pkg = new Package( project.getRootPath(),
mainSrcPath,