diff options
author | dimdim11 <dimdim11@yandex-team.com> | 2024-11-07 08:02:04 +0300 |
---|---|---|
committer | dimdim11 <dimdim11@yandex-team.com> | 2024-11-07 08:16:28 +0300 |
commit | 92eae04ea0abbbe3cf1c22a77848f0ae3133eb18 (patch) | |
tree | a848f5bb7a2be2c2b3cd2d3b775bb14f54386e42 | |
parent | c3aec4b741e41998e2f9c0fd33d60db563bb7eb3 (diff) | |
download | ydb-92eae04ea0abbbe3cf1c22a77848f0ae3133eb18.tar.gz |
User-freindly error on pom.xml parse error in java macroses
User-freindly error on pom.xml parse error in java macroses
commit_hash:775254d939c99c4e0b685f17a69b7dbbab8dfa78
-rw-r--r-- | build/plugins/java.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/build/plugins/java.py b/build/plugins/java.py index 4b49fd8dac..bc9d624a69 100644 --- a/build/plugins/java.py +++ b/build/plugins/java.py @@ -406,16 +406,19 @@ def _maven_coords_for_project(unit, project_dir): if os.path.exists(pom_path): import xml.etree.ElementTree as et - with open(pom_path, 'rb') as f: - root = et.fromstring(f.read()) - for xpath in ('./{http://maven.apache.org/POM/4.0.0}artifactId', './artifactId'): - artifact = root.find(xpath) - if artifact is not None: - artifact = artifact.text - if a != artifact and a.startswith(artifact): - c = a[len(artifact) :].lstrip('-_') - a = artifact - break + try: + with open(pom_path, 'rb') as f: + root = et.fromstring(f.read()) + for xpath in ('./{http://maven.apache.org/POM/4.0.0}artifactId', './artifactId'): + artifact = root.find(xpath) + if artifact is not None: + artifact = artifact.text + if a != artifact and a.startswith(artifact): + c = a[len(artifact) :].lstrip('-_') + a = artifact + break + except Exception as e: + raise Exception(f"Can't parse {pom_path}: {str(e)}") from None return '{}:{}:{}:{}'.format(g, a, v, c) |