java.lang.Object
io.helidon.inject.tools.ModuleUtils
Module specific utils.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The file name written to ./target/inject/ to track the last package name generated for this application.static final String
The injection generated (e.g., module-info.java.inject) file name.static final String
The "real" module-info.java file name. -
Method Summary
Modifier and TypeMethodDescriptionstatic String
inferSourceOrTest
(Path path) Attempts to infer 'test' or base '' given the path.static boolean
isUnnamedModuleName
(String moduleName) Returns true if the given module name is unnamed.loadAppPackageName
(Path scratchPath) Attempts to load the app package name from what was previously recorded.static void
saveAppPackageName
(Path scratchPath, String packageName) Persist the package name into scratch for later usage.static Path
toBasePath
(String sourcePath) Returns the base module path given its source path.toSourcePath
(Path filePath, TypeElement type) Translates to the source path coordinate given a source file and type name.static String
toSuggestedGeneratedPackageName
(Collection<TypeName> typeNames, String defaultPackageName) Returns the suggested package name to use.static String
toSuggestedGeneratedPackageName
(Collection<TypeName> typeNames, String defaultPackageName, io.helidon.inject.tools.ModuleInfoDescriptor descriptor) Returns the suggested package name to use.toSuggestedModuleName
(Path basePath, Path sourcePath, boolean defaultToUnnamed) Extract the module name, first attempting the source path (test or main), and if not found using the base path, presumably having basePath being a parent in the sourcePath hierarchy.
-
Field Details
-
REAL_MODULE_INFO_JAVA_NAME
The "real" module-info.java file name.- See Also:
-
MODULE_INFO_JAVA_NAME
The injection generated (e.g., module-info.java.inject) file name.- See Also:
-
APPLICATION_PACKAGE_FILE_NAME
The file name written to ./target/inject/ to track the last package name generated for this application. This application package name is what we fall back to for the application name and the module name if not otherwise specified directly.- See Also:
-
-
Method Details
-
toSuggestedGeneratedPackageName
public static String toSuggestedGeneratedPackageName(Collection<TypeName> typeNames, String defaultPackageName, io.helidon.inject.tools.ModuleInfoDescriptor descriptor) Returns the suggested package name to use.- Parameters:
typeNames
- the set of types that are being code generateddefaultPackageName
- the default package name to use if all options are exhausteddescriptor
- the module-info descriptor- Returns:
- the suggested package name
-
toSuggestedGeneratedPackageName
public static String toSuggestedGeneratedPackageName(Collection<TypeName> typeNames, String defaultPackageName) Returns the suggested package name to use.- Parameters:
typeNames
- the set of types that are being code generateddefaultPackageName
- the default package name to use if all options are exhausted- Returns:
- the suggested package name
-
toSuggestedModuleName
public static Optional<String> toSuggestedModuleName(Path basePath, Path sourcePath, boolean defaultToUnnamed) Extract the module name, first attempting the source path (test or main), and if not found using the base path, presumably having basePath being a parent in the sourcePath hierarchy.- Parameters:
basePath
- the secondary path to try if module-info was not found in the source pathsourcePath
- the source pathdefaultToUnnamed
- if true, will return the default name, otherwise empty is returned- Returns:
- the module name suggested to use, most appropriate for the name of
Application
orModuleComponent
-
inferSourceOrTest
Attempts to infer 'test' or base '' given the path.- Parameters:
path
- the path- Returns:
- 'test' or '' (for base non-test)
-
toSourcePath
Translates to the source path coordinate given a source file and type name. Only available during annotation processing.- Parameters:
filePath
- the source file pathtype
- the type name- Returns:
- the source path, or empty if it cannot be inferred
-
toBasePath
Returns the base module path given its source path.- Parameters:
sourcePath
- the source path- Returns:
- the base path
-
isUnnamedModuleName
Returns true if the given module name is unnamed.- Parameters:
moduleName
- the module name to check- Returns:
- true if the provided module name is unnamed
-
loadAppPackageName
Attempts to load the app package name from what was previously recorded.- Parameters:
scratchPath
- the scratch directory path- Returns:
- the app package name that was loaded
-
saveAppPackageName
Persist the package name into scratch for later usage.- Parameters:
scratchPath
- the scratch directory pathpackageName
- the package name- Throws:
ToolsException
- if there are any errors creating or writing the content
-