fix Test tasks in terms of Gradle task caching
This commit is contained in:
parent
476ea9230e
commit
d1ab98df85
|
@ -230,6 +230,20 @@ if ( gradle.ext.javaToolchainEnabled ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
class HeapDumpPathProvider implements CommandLineArgumentProvider {
|
||||||
|
// @InputFile
|
||||||
|
@OutputFile
|
||||||
|
@PathSensitive(PathSensitivity.RELATIVE)
|
||||||
|
// @Optional
|
||||||
|
Provider<RegularFile> path
|
||||||
|
// File path
|
||||||
|
|
||||||
|
@Override
|
||||||
|
Iterable<String> asArguments() {
|
||||||
|
["-XX:HeapDumpPath=${path.get().asFile.absolutePath}"]
|
||||||
|
// ["-XX:HeapDumpPath=${path.absolutePath}"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tasks.withType( Test.class ).each { test ->
|
tasks.withType( Test.class ).each { test ->
|
||||||
test.useJUnitPlatform()
|
test.useJUnitPlatform()
|
||||||
|
@ -240,9 +254,14 @@ tasks.withType( Test.class ).each { test ->
|
||||||
// Byteman needs this property to be set, https://developer.jboss.org/thread/274997
|
// Byteman needs this property to be set, https://developer.jboss.org/thread/274997
|
||||||
test.jvmArgs += ["-Djdk.attach.allowAttachSelf=true"]
|
test.jvmArgs += ["-Djdk.attach.allowAttachSelf=true"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test.jvmArgumentProviders.add(
|
||||||
|
new HeapDumpPathProvider( path: project.layout.buildDirectory.file("OOM-dump.hprof") )
|
||||||
|
// new HeapDumpPathProvider( path: project.file( "${buildDir}/OOM-dump.hprof" ) )
|
||||||
|
)
|
||||||
|
|
||||||
test.jvmArgs += [
|
test.jvmArgs += [
|
||||||
'-XX:+HeapDumpOnOutOfMemoryError',
|
'-XX:+HeapDumpOnOutOfMemoryError',
|
||||||
"-XX:HeapDumpPath=${file( "${buildDir}/OOM-dump.hprof" ).absolutePath}",
|
|
||||||
'-XX:MetaspaceSize=256M'
|
'-XX:MetaspaceSize=256M'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
/*
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
package org.hibernate.orm;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.Collections;
|
||||||
|
|
||||||
|
import org.gradle.api.Project;
|
||||||
|
import org.gradle.api.file.RegularFile;
|
||||||
|
import org.gradle.api.file.RegularFileProperty;
|
||||||
|
import org.gradle.api.tasks.InputDirectory;
|
||||||
|
import org.gradle.api.tasks.PathSensitive;
|
||||||
|
import org.gradle.api.tasks.PathSensitivity;
|
||||||
|
import org.gradle.process.CommandLineArgumentProvider;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Steve Ebersole
|
||||||
|
*/
|
||||||
|
public class FileCommandLineArgumentProvider implements CommandLineArgumentProvider {
|
||||||
|
private final String argumentName;
|
||||||
|
|
||||||
|
@InputDirectory
|
||||||
|
@PathSensitive(PathSensitivity.RELATIVE)
|
||||||
|
RegularFileProperty path;
|
||||||
|
|
||||||
|
public FileCommandLineArgumentProvider(String argumentName, Project project) {
|
||||||
|
this.argumentName = argumentName;
|
||||||
|
path = project.getObjects().fileProperty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileCommandLineArgumentProvider(String argumentName, RegularFile path, Project project) {
|
||||||
|
this( argumentName, project );
|
||||||
|
this.path.set( path );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Iterable<String> asArguments() {
|
||||||
|
final File pathAsFile = path.get().getAsFile();
|
||||||
|
return Collections.singleton(
|
||||||
|
String.format(
|
||||||
|
"-D%s=%s",
|
||||||
|
argumentName,
|
||||||
|
pathAsFile.getAbsolutePath()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue