--force clearOutput removes output directory, improved logging it
This commit is contained in:
@@ -108,11 +108,13 @@ def task_resources() -> int:
|
|||||||
description="Optionally deletes the output folder; has no effect by default."
|
description="Optionally deletes the output folder; has no effect by default."
|
||||||
)
|
)
|
||||||
def task_clear_output(force: bool = False) -> int:
|
def task_clear_output(force: bool = False) -> int:
|
||||||
if GLOBALS.MAKE_CONFIG.get_value("development.clearOutput", False) or force:
|
from .package import pretty_cleanup_directory
|
||||||
GLOBALS.PROJECT_STRUCTURE.cleanup(clear_output=True)
|
|
||||||
if PROPERTIES.get_value("release"):
|
if PROPERTIES.get_value("release"):
|
||||||
from .package import pretty_cleanup_directory
|
|
||||||
pretty_cleanup_directory(GLOBALS.MAKE_CONFIG.get_build_path())
|
pretty_cleanup_directory(GLOBALS.MAKE_CONFIG.get_build_path())
|
||||||
|
if force or GLOBALS.MAKE_CONFIG.get_value("development.clearOutput", False):
|
||||||
|
GLOBALS.PROJECT_STRUCTURE.cleanup(clear_output=True)
|
||||||
|
if force or PROPERTIES.get_value("release"):
|
||||||
|
pretty_cleanup_directory(GLOBALS.PROJECT_STRUCTURE.directory)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@task(
|
@task(
|
||||||
|
|||||||
@@ -44,6 +44,7 @@ def collect_classpath_files(directories: Collection[str]) -> List[str]:
|
|||||||
continue
|
continue
|
||||||
libraries = get_all_files(classpath_directory, (".jar"))
|
libraries = get_all_files(classpath_directory, (".jar"))
|
||||||
classpath.extend(libraries)
|
classpath.extend(libraries)
|
||||||
|
|
||||||
global TOOLCHAIN_CLASSPATH
|
global TOOLCHAIN_CLASSPATH
|
||||||
if not TOOLCHAIN_CLASSPATH:
|
if not TOOLCHAIN_CLASSPATH:
|
||||||
from .output_directory import get_config_directory
|
from .output_directory import get_config_directory
|
||||||
@@ -56,6 +57,7 @@ def collect_classpath_files(directories: Collection[str]) -> List[str]:
|
|||||||
TOOLCHAIN_CLASSPATH.remove(innercore_test)
|
TOOLCHAIN_CLASSPATH.remove(innercore_test)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
attention("Failed to exclude 'innercore-test.jar' from classpath for package build, contact developer and tell them they are a arsehole.")
|
attention("Failed to exclude 'innercore-test.jar' from classpath for package build, contact developer and tell them they are a arsehole.")
|
||||||
|
|
||||||
if TOOLCHAIN_CLASSPATH:
|
if TOOLCHAIN_CLASSPATH:
|
||||||
classpath.extend(TOOLCHAIN_CLASSPATH)
|
classpath.extend(TOOLCHAIN_CLASSPATH)
|
||||||
return classpath
|
return classpath
|
||||||
|
|||||||
@@ -31,8 +31,9 @@ def get_path_set(locations: List[str], error_sensitive: bool = False) -> Optiona
|
|||||||
|
|
||||||
def pretty_cleanup_directory(path: str) -> None:
|
def pretty_cleanup_directory(path: str) -> None:
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
remove_tree(GLOBALS.TOOLCHAIN_CONFIG.get_path(path))
|
absolute_path = GLOBALS.TOOLCHAIN_CONFIG.get_path(path)
|
||||||
success(f"Completed {basename(path)} cleanup in {int((time.time() - start_time) * 100) / 100}s")
|
if remove_tree(absolute_path):
|
||||||
|
success(f"Completed {basename(path)} cleanup in {int((time.time() - start_time) * 100) / 100}s")
|
||||||
|
|
||||||
def collect_project_templates() -> List[str]:
|
def collect_project_templates() -> List[str]:
|
||||||
templates = []
|
templates = []
|
||||||
|
|||||||
@@ -48,16 +48,20 @@ def ensure_file(path: str) -> None:
|
|||||||
if isdir(path) or islink(path):
|
if isdir(path) or islink(path):
|
||||||
move_to_backup(path)
|
move_to_backup(path)
|
||||||
|
|
||||||
def remove_tree(directory: str) -> None:
|
def remove_tree(directory: str) -> bool:
|
||||||
"""
|
"""
|
||||||
Removes existing files, directories and links recursive.
|
Removes existing files, directories and links recursive.
|
||||||
"""
|
"""
|
||||||
if not exists(directory):
|
if not exists(directory):
|
||||||
return
|
return False
|
||||||
if isfile(directory) or islink(directory):
|
if isfile(directory) or islink(directory):
|
||||||
os.remove(directory)
|
os.remove(directory)
|
||||||
return
|
return True
|
||||||
shutil.rmtree(directory, ignore_errors=True)
|
try:
|
||||||
|
shutil.rmtree(directory, ignore_errors=False)
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
return True
|
||||||
|
|
||||||
def copy_file(source: str, destination: str) -> None:
|
def copy_file(source: str, destination: str) -> None:
|
||||||
"""
|
"""
|
||||||
@@ -66,6 +70,7 @@ def copy_file(source: str, destination: str) -> None:
|
|||||||
"""
|
"""
|
||||||
source = abspath(source)
|
source = abspath(source)
|
||||||
destination = abspath(destination)
|
destination = abspath(destination)
|
||||||
|
|
||||||
ensure_file_directory(destination)
|
ensure_file_directory(destination)
|
||||||
try:
|
try:
|
||||||
shutil.copy(source, destination)
|
shutil.copy(source, destination)
|
||||||
|
|||||||
Reference in New Issue
Block a user