Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix javadoc and warnings #291

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ nativeBuildTools = "0.9.14-SNAPSHOT"

# External dependencies
spock = "2.1-groovy-3.0"
maven = "3.8.5"
maven = "3.8.6"
mavenAnnotations = "3.6.4"
mavenEmbedder = "3.8.3"
mavenEmbedder = "3.8.6"
mavenWagon = "3.4.3"
graalvm = "22.0.0"
jackson = "2.13.3"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
import org.gradle.process.JavaForkOptions;
import org.gradle.util.GFileUtils;

import javax.annotation.Nonnull;
import javax.inject.Inject;
import java.io.File;
import java.net.URI;
Expand All @@ -121,6 +122,7 @@
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -170,7 +172,7 @@ public FileSystemOperations getFileOperations() {


@Override
public void apply(Project project) {
public void apply(@Nonnull Project project) {
Provider<NativeImageService> nativeImageServiceProvider = NativeImageService.registerOn(project);

logger = GraalVMLogger.of(project.getLogger());
Expand Down Expand Up @@ -231,7 +233,7 @@ private void configureJavaProject(Project project, Provider<NativeImageService>
deprecateExtension(project, mainOptions, DEPRECATED_NATIVE_BUILD_EXTENSION, "main");

project.getPlugins().withId("application", p -> mainOptions.getMainClass().convention(
project.getExtensions().findByType(JavaApplication.class).getMainClass()
Objects.requireNonNull(project.getExtensions().findByType(JavaApplication.class)).getMainClass()
));

project.getPlugins().withId("java-library", p -> mainOptions.getSharedLibrary().convention(true));
Expand Down Expand Up @@ -326,7 +328,7 @@ private void configureJvmReachabilityConfigurationDirectories(Project project, G
Map<String, String> forcedVersions = repositoryExtension.getModuleToConfigVersion().getOrElse(Collections.emptyMap());
return serviceProvider.map(repo -> repo.findConfigurationDirectoriesFor(query -> classpath.getIncoming().getResolutionResult().allComponents(component -> {
ModuleVersionIdentifier moduleVersion = component.getModuleVersion();
String module = moduleVersion.getGroup() + ":" + moduleVersion.getName();
String module = Objects.requireNonNull(moduleVersion).getGroup() + ":" + moduleVersion.getName();
if (!excludedModules.contains(module)) {
query.forArtifact(artifact -> {
artifact.gav(module + ":" + moduleVersion.getVersion());
Expand Down Expand Up @@ -428,7 +430,7 @@ private void configureNativeConfigurationRepo(ExtensionAware graalvmNative) {
try {
return new URI(String.format(METADATA_REPO_URL_TEMPLATE, v));
} catch (URISyntaxException e) {
return null;
throw new RuntimeException(e);
}
}));
configurationRepository.getExcludedModules().convention(Collections.emptySet());
Expand Down Expand Up @@ -562,7 +564,7 @@ private static NativeConfigurations createNativeConfigurations(Project project,
for (Attribute<?> attribute : baseAttributes.keySet()) {
Attribute<Object> attr = (Attribute<Object>) attribute;
Object value = baseAttributes.getAttribute(attr);
attrs.attribute(attr, value);
attrs.attribute(attr, Objects.requireNonNull(value));
}
});
});
Expand Down Expand Up @@ -653,7 +655,12 @@ private static void setupExtensionConfigExcludes(NativeImageOptions options, Nat
}

private static List<String> agentSessionDirectories(Directory outputDirectory) {
return Arrays.stream(outputDirectory.getAsFile().listFiles(file -> file.isDirectory() && file.getName().startsWith("session-"))).map(File::getAbsolutePath).collect(Collectors.toList());
return Arrays.stream(Objects.requireNonNull(
outputDirectory.getAsFile()
.listFiles(file -> file.isDirectory() && file.getName().startsWith("session-"))
)
).map(File::getAbsolutePath)
.collect(Collectors.toList());
}

private void configureAgent(Project project,
Expand All @@ -667,7 +674,7 @@ private void configureAgent(Project project,
//noinspection Convert2Lambda
taskToInstrument.doFirst(new Action<Task>() {
@Override
public void execute(Task task) {
public void execute(@Nonnull Task task) {
if (agentConfiguration.get().isEnabled()) {
logger.logOnce("Instrumenting task with the native-image-agent: " + task.getName());
}
Expand Down Expand Up @@ -725,7 +732,7 @@ private CleanupTestIdsDirectory(DirectoryProperty directory) {
}

@Override
public void execute(Task task) {
public void execute(@Nonnull Task task) {
File dir = directory.getAsFile().get();
if (dir.exists()) {
GFileUtils.deleteDirectory(dir);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public interface GraalVMExtension {
* to disable automatic test support, especially in cases
* where the test framework doesn't allow testing within
* a native image.
*
* @return is the test support active
*/
Property<Boolean> getTestSupport();

Expand All @@ -76,24 +78,31 @@ public interface GraalVMExtension {
* Returns the native image configurations used to generate images.
* By default, this plugin creates two images, one called "main" for
* the main application and another one called "test" for tests.
*
* @return configuration for binaries
*/
NamedDomainObjectContainer<NativeImageOptions> getBinaries();

/**
* Configures the native image options.
*
* @param spec specification for binary
*/
void binaries(Action<? super NamedDomainObjectContainer<NativeImageOptions>> spec);

/**
* Registers a new native image binary with testing support.
*
* @param name the name of the binary
* @param spec the test image configuration
*/
void registerTestBinary(String name, Action<? super TestBinaryConfig> spec);

/**
* Property driving the detection of toolchains which support building native images.
* The default is true.
*
* @return is toolchain detection on
*/
Property<Boolean> getToolchainDetection();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public interface GraalVMReachabilityMetadataRepositoryExtension {
/**
* Property used to determine if the reachability metadata
* repository should be used.
*
* @return the enabled property
*/
Property<Boolean> getEnabled();
Expand All @@ -81,28 +82,33 @@ public interface GraalVMReachabilityMetadataRepositoryExtension {
* The set of modules for which we don't want to use the
* configuration found in the repository. Modules must be
* declared with the `groupId:artifactId` syntax.
*
* @return the set of excluded modules
*/
SetProperty<String> getExcludedModules();

/**
* A map from a module (org.group:artifact) to configuration
* repository config version.
*
* @return the map of modules to forced configuration versions
*/
MapProperty<String, String> getModuleToConfigVersion();

/**
* Convenience method to use a String for the URI
* property.
*
* @param uri the URI
* @throws URISyntaxException if URL is malformed
*/
default void uri(String uri) throws URISyntaxException {
getUri().set(new URI(uri));
}

/**
* Convenience method to use a URI for the property.
*
* @param file a file
*/
default void uri(File file) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ public interface NativeImageOptions extends Named {
/**
* Returns the toolchain used to invoke native-image. Currently pointing
* to a Java launcher due to Gradle limitations.
*
* @return the detected java launcher
*/
@Nested
@Optional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ public void autodetect() {
* The list of bundles to include in the generated resources file.
* The contents of this property is used to generate the "bundles"
* section of the resource-config.json file
*
* @return the list of bundles
*/
@Input
public abstract ListProperty<String> getBundles();
Expand All @@ -74,9 +76,9 @@ public void autodetect() {
* The list of resources to include, as Java regular expressions.
* The contents of this property is used to generate the "resources" : "includes"
* section of the resource-config.json file.
*
* It will be merged with detected resources, if any.
*
* @return the list of resources to include
*/
@Input
public abstract ListProperty<String> getIncludedPatterns();
Expand All @@ -85,9 +87,9 @@ public void autodetect() {
* The list of resources to exclude, as Java regular expressions.
* The contents of this property is used to generate the "resources" : "excludes"
* section of the resource-config.json file.
*
* It will be merged with detected resources, if any.
*
* @return the list of resources to exclude
*/
@Input
public abstract ListProperty<String> getExcludedPatterns();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,18 @@ public abstract class ResourceDetectionOptions {
* Determines if the resources should be detected from classpath.
* If this property is set to true, then Gradle will automatically
* detect resources to include from conventional places like src/main/resources.
*
* @return if resources should be detected from the classpath
*/
@Input
public abstract Property<Boolean> getEnabled();

/**
* Determines if detection should be limited to project dependencies, in
* which case external dependencies will not be scanned.
*
* Default value is true.
*
* @return if detection should be limited to the project dependencies
*/
@Input
public abstract Property<Boolean> getRestrictToProjectDependencies();
Expand All @@ -69,6 +72,7 @@ public abstract class ResourceDetectionOptions {
* that classpath entry (e.g jar). By default, this behavior is set to false,
* meaning that if such a file is present, detection is disabled for this
* particular classpath entry.
*
* @return the ignore property
*/
@Input
Expand All @@ -77,6 +81,8 @@ public abstract class ResourceDetectionOptions {
/**
* Returns the list of regular expressions which will be used to exclude
* resources from detection.
*
* @return a list of regular expressions for resources exclusion
*/
@Input
public abstract SetProperty<String> getDetectionExclusionPatterns();
Expand All @@ -85,6 +91,8 @@ public abstract class ResourceDetectionOptions {
* Adds the default resource excludes for detection, which can be useful if
* you want to add more excludes but still want the conventional ones to be
* added.
*
* @return resource detection options
*/
public ResourceDetectionOptions addDefaultDetectionExclusions() {
getDetectionExclusionPatterns().addAll(SharedConstants.DEFAULT_EXCLUDES_FOR_RESOURCE_DETECTION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
public interface AgentOptions {
/**
* Contains configuration of supported agent modes.
* @return agent modes
*/
@Nested
AgentModeOptions getModes();
Expand All @@ -67,67 +68,77 @@ default void modes(Action<? super AgentModeOptions> spec) {

/**
* The default agent mode name when the agent is in use.
* @return default agent mode
*/
@Input
@Optional
Property<String> getDefaultMode();

/**
* Enables the agent.
* @return is the agent enabled
*/
@Input
@Optional
Property<Boolean> getEnabled();

/**
* Caller-filter files that will be passed to the agent.
* @return caller filter files
*/
@InputFiles
@Optional
ConfigurableFileCollection getCallerFilterFiles();

/**
* Access-filter files that will be passed to the agent.
* @return access filter files
*/
@InputFiles
@Optional
ConfigurableFileCollection getAccessFilterFiles();

/**
* Toggles the builtin agent caller filter.
* @return builtin caller filter
*/
@Optional
Property<Boolean> getBuiltinCallerFilter();

/**
* Toggles the builtin agent heuristic filter.
* @return is builtin heuristic filter enabled
*/
@Optional
Property<Boolean> getBuiltinHeuristicFilter();


/**
* Toggles the experimental support for predefined classes.
* @return is experimental support for predefined classes enabled
*/
@Optional
Property<Boolean> getEnableExperimentalPredefinedClasses();


/**
* Toggles the experimental support for unsafe allocation tracing.
* @return is experimental support for unsafe allocation tracing enabled
*/
@Optional
Property<Boolean> getEnableExperimentalUnsafeAllocationTracing();


/**
* Toggles the distinction between queried and used metadata.
* @return queried or used metadata
*/
@Optional
Property<Boolean> getTrackReflectionMetadata();

/**
* Configuration of the metadata copy task.
* @return configuration of the metadata copy task
*/
@Nested
MetadataCopyOptions getMetadataCopy();
Expand All @@ -138,6 +149,7 @@ default void metadataCopy(Action<? super MetadataCopyOptions> spec) {

/**
* Specifies prefixes that will be used to further filter files produced by the agent.
* @return filterable entries
*/
@Input
@Optional
Expand Down