Class FileHandling
java.lang.Object
org.ek9lang.core.FileHandling
Designed to abstract out all file handling for the compiler.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringSystem property naming the library folder, instead of~/.ek9/lib: tests point it at a fixture library holding a stub of each package they declare.static final StringTHE file-name prefix of every cached runtime jar in<projectDir>/.ek9/runtime/; the extractor removes any entry under it that is not the current one. -
Constructor Summary
ConstructorsConstructorDescriptionFileHandling(OsSupport osSupport) Create File Handling with the appropriately configured OS support. -
Method Summary
Modifier and TypeMethodDescriptionvoidcleanEk9DirectoryStructureFor(File ek9File, TargetArchitecture targetArchitecture) voidcleanEk9DirectoryStructureFor(String ek9FullPathToFileName, TargetArchitecture targetArchitecture) booleanCopy a file to a new destination.booleanCopy a named file from a source directory to a destination directory.booleanCreate a Java jar file with a list of zip sets.booleanCreate a Java jar file with a list of zip sets and optional Main-Class manifest.voidcreateOrRecreateFile(File file) createSha256Of(String fileName) Create a sha256 hash of a file and save it in fileName".sha256"booleanTo be used for making the zip when publishing ek9 source to artefact server.voiddeleteContentsAndBelow(File dir, boolean includeDirectoryRoot) Does a recursive delete from this directory and below.voiddeleteFileIfExists(File file) Deletes a file if it exists.voiddeleteMatchingFiles(File dir, String fileNamePattern) deletes matching files.voiddeleteStalePackages(String ek9FileNameDirectory, String moduleName) The library folder as aDependencyInstallation: where a dependency is unpacked or zipped.getDevFinalOutputDirectory(String fromEk9BaseDirectory, TargetArchitecture targetArchitecture) getDevGeneratedOutputDirectory(String fromEk9BaseDirectory, TargetArchitecture targetArchitecture) getDotEk9Directory(File directory) getDotEk9Directory(String fromDirectory) getMainFinalOutputDirectory(String fromEk9BaseDirectory, TargetArchitecture targetArchitecture) getMainGeneratedOutputDirectory(String fromEk9BaseDirectory, TargetArchitecture targetArchitecture) getRuntimeDirectory(String projectDir) Get the per-project runtime cache directory.getRuntimeJarFile(String projectDir, String version, String contentHash) Get the cached runtime JAR file path, keyed on the compiler version AND the content hash of the runtime classes - a development build keeps its version while its runtime changes, so the version alone let a stale runtime be packaged (seeRuntimeContentHash).getTargetExecutableArtefact(String ek9FullPathToFileName, TargetArchitecture targetArchitecture) getTargetPropertiesArtefact(String ek9FullPathToFileName) THE library folder dependencies are installed into and resolved from: the folder named by the system property "ek9.library.directory" when set (never in a stub-mode sandbox, which keeps its own home), else~/.ek9/lib.booleanmakeDependencyVector(String moduleName, String version) Create a full dependency vector out of module name and version.voidmakeDirectoryIfNotExists(File directory) Create a directory.makePackagedModuleZipFileName(String dependencyVector) makePackagedModuleZipFileName(String moduleName, String version) booleansaveToHomeEk9Directory(SigningKeyPair keyPair) booleansaveToOutput(File file, String value) Save some text to a file.booleanunZipFileTo(File zipFile, File unpackedDir) Unzips a zip file into a directory, the directory will be created if it does not exist.booleanunZipFileTo(File zipFile, String unpackedDir) voidvalidateEk9Directory(String directoryName, TargetArchitecture targetArchitecture) voidvalidateHomeEk9Directory(TargetArchitecture targetArchitecture)
-
Field Details
-
LIBRARY_DIRECTORY_PROPERTY
System property naming the library folder, instead of~/.ek9/lib: tests point it at a fixture library holding a stub of each package they declare.- See Also:
-
RUNTIME_JAR_PREFIX
THE file-name prefix of every cached runtime jar in<projectDir>/.ek9/runtime/; the extractor removes any entry under it that is not the current one.- See Also:
-
-
Constructor Details
-
FileHandling
Create File Handling with the appropriately configured OS support. Quite a few of these methods just delegate to OsSupport and the Packager.
-
-
Method Details
-
getTempDirectory
-
getUsersHomeDirectory
-
getUsersHomeEk9LibDirectory
THE library folder dependencies are installed into and resolved from: the folder named by the system property "ek9.library.directory" when set (never in a stub-mode sandbox, which keeps its own home), else~/.ek9/lib. Every reader and writer of the library goes through here - the property is read nowhere else. -
dependencyInstallation
The library folder as aDependencyInstallation: where a dependency is unpacked or zipped. -
getUsersHomeEk9Directory
-
getDotEk9Directory
-
getDotEk9Directory
-
makePackagedModuleZipFileName
-
makePackagedModuleZipFileName
-
makeDependencyVector
-
copy
-
copy
-
saveToOutput
-
deleteFileIfExists
Deletes a file if it exists. -
makeDirectoryIfNotExists
Create a directory. -
createOrRecreateFile
-
deleteMatchingFiles
-
deleteContentsAndBelow
Does a recursive delete from this directory and below. If includeDirectoryRoot is true then it will delete that directory as well -
createSha256Of
Create a sha256 hash of a file and save it in fileName".sha256" -
createJar
-
createJar
Create a Java jar file with a list of zip sets and optional Main-Class manifest.- Parameters:
fileName- The name of the JAR file to createsets- The list of ZipSets to includemainClass- The fully-qualified main class name for manifest (null for no Main-Class)- Returns:
- true if JAR creation successful
-
unZipFileTo
-
unZipFileTo
-
createZip
To be used for making the zip when publishing ek9 source to artefact server.- Parameters:
fileName- The name of the zip to createsourcePropertiesFile- The properties file that describes the package.- Returns:
- true if all OK.
-
getTargetExecutableArtefact
public File getTargetExecutableArtefact(String ek9FullPathToFileName, TargetArchitecture targetArchitecture) -
getTargetPropertiesArtefact
-
getRuntimeDirectory
-
getRuntimeJarFile
Get the cached runtime JAR file path, keyed on the compiler version AND the content hash of the runtime classes - a development build keeps its version while its runtime changes, so the version alone let a stale runtime be packaged (seeRuntimeContentHash). Pattern:<projectDir>/.ek9/runtime/ek9-runtime-<version>-<contentHash>.jar -
validateHomeEk9Directory
-
validateEk9Directory
-
cleanEk9DirectoryStructureFor
-
cleanEk9DirectoryStructureFor
public void cleanEk9DirectoryStructureFor(String ek9FullPathToFileName, TargetArchitecture targetArchitecture) -
getMainGeneratedOutputDirectory
public File getMainGeneratedOutputDirectory(String fromEk9BaseDirectory, TargetArchitecture targetArchitecture) -
getMainFinalOutputDirectory
public File getMainFinalOutputDirectory(String fromEk9BaseDirectory, TargetArchitecture targetArchitecture) -
getDevGeneratedOutputDirectory
public File getDevGeneratedOutputDirectory(String fromEk9BaseDirectory, TargetArchitecture targetArchitecture) -
getDevFinalOutputDirectory
public File getDevFinalOutputDirectory(String fromEk9BaseDirectory, TargetArchitecture targetArchitecture) -
deleteStalePackages
-
isUsersSigningKeyPairPresent
public boolean isUsersSigningKeyPairPresent() -
getUsersSigningKeyPair
-
saveToHomeEk9Directory
-