Skip to content
This repository was archived by the owner on Apr 8, 2025. It is now read-only.

Commit 72fc104

Browse files
committed
Handle mvnw in run-crate build from source
1 parent 9244754 commit 72fc104

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

cr8/run_crate.py

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -570,26 +570,43 @@ def _lookup_uri(version):
570570

571571

572572
def _is_project_repo(src_repo):
573-
return (os.path.isdir(src_repo) and
574-
os.path.exists(os.path.join(src_repo, '.git')) and
575-
os.path.exists(os.path.join(src_repo, 'gradlew')))
573+
path = Path(src_repo)
574+
return (path.is_dir()
575+
and (path / ".git").exists()
576+
and ((path / "gradlew").exists() or (path / "mvnw").exists())
577+
)
576578

577579

578580
def _build_tarball(src_repo) -> Path:
579581
""" Build a tarball from src and return the path to it """
580582
run = partial(subprocess.run, cwd=src_repo, check=True, stdin=subprocess.DEVNULL)
581583
run(['git', 'clean', '-xdff'])
582-
src_repo = Path(src_repo)
583-
if os.path.exists(src_repo / 'es' / 'upstream'):
584+
path = Path(src_repo)
585+
if (path / 'es' / 'upstream').exists():
584586
run(['git', 'submodule', 'update', '--init', '--', 'es/upstream'])
585-
run(['./gradlew', '--parallel', '--no-daemon', 'clean', 'distTar'])
586-
distributions = Path(src_repo) / 'app' / 'build' / 'distributions'
587+
if (path / "mvnw").exists():
588+
run([
589+
"mvnw",
590+
"clean",
591+
"package",
592+
"-DskipTests=true",
593+
"-Dcheckstyle.skip",
594+
"-Djacoco.skip=true"
595+
])
596+
distributions = path / "app" / "target"
597+
else:
598+
run(['./gradlew', '--parallel', '--no-daemon', 'clean', 'distTar'])
599+
distributions = path / 'app' / 'build' / 'distributions'
587600
return next(distributions.glob('crate-*.tar.gz'))
588601

589602

590603
def _extract_tarball(tarball):
591604
with tarfile.open(tarball) as t:
592-
folder_name = t.getnames()[0]
605+
first_file = t.getnames()[0]
606+
# First file name might be the folder, or a file inside the folder
607+
# Normalize to folder
608+
folder_name = os.path.dirname(first_file)
609+
folder_name = folder_name == "" and first_file or folder_name
593610
t.extractall(tarball.parent)
594611
return str(tarball.parent / folder_name)
595612

@@ -701,7 +718,7 @@ def create_node(
701718
):
702719
init_logging(log)
703720
settings = {
704-
'cluster.name': 'cr8-crate-run' + str(random.randrange(1e9))
721+
'cluster.name': 'cr8-crate-run' + str(random.randrange(int(1e9)))
705722
}
706723
crate_dir = get_crate(version, crate_root)
707724
if setting:

0 commit comments

Comments
 (0)