2013-01-23 18:22:03 -05:00
|
|
|
|
|
|
|
apply plugin: UtilitiesPlugin
|
|
|
|
|
2015-05-19 00:23:35 -04:00
|
|
|
/*
|
|
|
|
* Hibernate, Relational Persistence for Idiomatic Java
|
|
|
|
*
|
|
|
|
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
|
|
|
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
|
|
|
*/
|
2013-12-02 21:53:19 -05:00
|
|
|
class UtilitiesPlugin implements Plugin<Project> {
|
|
|
|
def void apply(Project project) {
|
2013-01-23 18:22:03 -05:00
|
|
|
project.convention.plugins.utilities = new UtilitiesPluginDef()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class UtilitiesPluginDef {
|
|
|
|
public String determinePackageName(SourceDirectorySet sourceDirectorySet, File javaFile) {
|
|
|
|
final javaFileAbsolutePath = javaFile.absolutePath;
|
|
|
|
for ( File sourceDirectory : sourceDirectorySet.srcDirs ) {
|
|
|
|
final String sourceDirectoryAbsolutePath = sourceDirectory.absolutePath;
|
|
|
|
if ( javaFileAbsolutePath.startsWith( sourceDirectoryAbsolutePath ) ) {
|
|
|
|
final String javaFileRelativePath = javaFileAbsolutePath.substring(
|
|
|
|
sourceDirectoryAbsolutePath.length() + 1,
|
|
|
|
javaFileAbsolutePath.lastIndexOf( File.separator )
|
|
|
|
);
|
|
|
|
return javaFileRelativePath.replace( File.separator, "." );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new RuntimeException( "ugh" );
|
|
|
|
}
|
2013-12-02 21:53:19 -05:00
|
|
|
}
|