forked from hibernate/hibernate-orm
-
Notifications
You must be signed in to change notification settings - Fork 5
/
utilities.gradle
44 lines (37 loc) · 1.58 KB
/
utilities.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
apply plugin: UtilitiesPlugin
/*
* 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>.
*/
class UtilitiesPlugin implements Plugin<Project> {
def void apply(Project project) {
project.convention.plugins.utilities = new UtilitiesPluginDef()
}
}
class UtilitiesPluginDef {
@SuppressWarnings("GrUnnecessarySemicolon")
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" );
}
String java9ModuleName(Project project) {
String name = project.name
// alternative is to just use the full project name (don't drop the 'hibernate-' prefix)
if ( name.startsWith( 'hibernate-' ) ) {
name = name.drop( 'hibernate-'.length() )
}
return name
}
}