Skip to content

Commit 8492d04

Browse files
committed
Fix published JARs
Fix the fix for #3
1 parent 63c492c commit 8492d04

File tree

2 files changed

+64
-28
lines changed

2 files changed

+64
-28
lines changed

README.md

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Or you can depend on the artifacts from maven central, they should be slightly m
4040
<dependency>
4141
<groupId>me.bechberger</groupId>
4242
<artifactId>ap-loader</artifactId>
43-
<version>2.9-1-all</version>
43+
<version>2.9-2-all</version>
4444
</dependency>
4545
```
4646

@@ -242,11 +242,11 @@ python3 ./bin/releaser.py download 2.9
242242
# build the JAR for the release
243243
# maven might throw warnings, related to the project version setting,
244244
# but the alternative solutions don't work, so we ignore the warning for now
245-
mvn -Dproject.versionPlatform=2.9-macos package assembly:single
245+
mvn -Dproject.vversion=2.9-macos -Dproject.subrelease=2 -Dproject.platform=macos package assembly:single
246246
# use it
247-
java -jar target/ap-loader-2.9-macos-full.jar ...
247+
java -jar target/ap-loader-2.9-2-macos-full.jar ...
248248
# build the all JAR
249-
mvn -Dproject.versionPlatform=2.9-all -f pom_all.xml package assembly:single
249+
mvn -Dproject.vversion=2.9 -Dproject.subrelease=2 -Dproject.platform=all package assembly:single
250250
```
251251
252252
Development
@@ -276,9 +276,29 @@ Commands:
276276
clear clear the ap-releases and target folders for a fresh start
277277
```
278278
279+
Deploy the latest version via ` bin/releaser.py download build test deploy` as a snapshot.
280+
281+
For a release use `bin/releaser.py download build test deploy_release`,
282+
but before make sure to do the following for a new sub release:
283+
284+
- increment the `SUB_VERSION` variable in `bin/releaser.py`
285+
- update the version number in the README
286+
- update the changelog in the README and `bin/releaser.py`
287+
288+
And the following for a new async-profiler release:
289+
- update the version in the README
290+
279291
Changelog
280292
---------
281293
294+
### v2
295+
- Fixed the library version in the pom #3 again
296+
(thanks to @gavlyukovskiy, @dpsoft and @krzysztofslusarski for spotting the bug)
297+
298+
### v1
299+
- Fixed the library version in the pom #3 (thanks to @gavlyukovskiy for spotting the bug)
300+
301+
### v0
282302
- 11.11.2022: Improve Converter
283303
284304
License

bin/releaser.py

Lines changed: 40 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
from typing import Any, Dict, List, Union, Tuple, Optional
1818
from urllib import request
1919

20-
SUB_VERSION = 1
21-
RELEASE_NOTES = """- Fixed the library version in the pom #3 (thanks to @gavlyukovskiy for spotting this)"""
20+
SUB_VERSION = 2
21+
RELEASE_NOTES = """- Fixed the library version in the pom #3 again (thanks to @gavlyukovskiy, @dpsoft and @krzysztofslusarski for spotting the bug)"""
2222

2323
HELP = """
2424
Usage:
@@ -47,25 +47,40 @@
4747

4848
def prepare_poms(release: str, platform: str, snapshot: bool = True) -> Tuple[str, str]:
4949
""" Prepare the POMs for the given release and platform """
50-
folder = f"{CACHE_DIR}/pom-{release}-{platform}"
50+
folder = CURRENT_DIR
5151
os.makedirs(folder, exist_ok=True)
52-
for pom in ["pom.xml", "pom_all.xml"]:
53-
pom_file = f"{CURRENT_DIR}/{pom}"
54-
dest_pom = f"{folder}/{pom}"
52+
suffix = f"-{release}-{platform}{'-SNAPSHOT' if snapshot else ''}"
53+
for pom in ["pom", "pom_all"]:
54+
pom_file = f"{CURRENT_DIR}/{pom}.xml"
55+
dest_pom = f"{folder}/{pom}{suffix}.xml"
5556
with open(pom_file) as f:
5657
pom_content = f.read()
57-
suffix = "-SNAPSHOT" if snapshot else ""
58-
pom_content = re.sub(r"<version>.*</version>", f"<version>{release}-{SUB_VERSION}-{platform}{suffix}</version>", pom_content, count = 1)
58+
p_suffix = "-SNAPSHOT" if snapshot else ""
59+
pom_content = re.sub(r"<version>.*</version>", f"<version>{release}-{SUB_VERSION}-{platform}{p_suffix}</version>", pom_content, count = 1)
5960
pom_content = re.sub(r"<project.vversion>.*</project.vversion>", f"<project.vversion>{release}</project.vversion>", pom_content, count = 1)
6061
pom_content = re.sub(r"<project.subversion>.*</project.subversion>", f"<project.subversion>{SUB_VERSION}</project.subversion>", pom_content, count = 1)
6162
pom_content = re.sub(r"<project.platform>.*</project.platform>", f"<project.platform>{platform}</project.platform>", pom_content, count = 1)
62-
pom_content = re.sub(r"<project.suffix>.*</project.suffix>", f"<project.suffix>{suffix}</project.suffix>", pom_content, count = 1)
63-
pom_content = pom_content.replace("${basedir}", "${basedir}/../..")
63+
pom_content = re.sub(r"<project.suffix>.*</project.suffix>", f"<project.suffix>{p_suffix}</project.suffix>", pom_content, count = 1)
6464
with open(dest_pom, "w") as f2:
6565
f2.write(pom_content)
66-
return f"{folder}/pom.xml", f"{folder}/pom_all.xml"
66+
return f"{folder}/pom{suffix}.xml", f"{folder}/pom_all{suffix}.xml"
6767

6868

69+
class PreparedPOMs:
70+
71+
def __init__(self, release: str, platform: str, snapshot: bool = True):
72+
self.release = release
73+
self.platform = platform
74+
self.snapshot = snapshot
75+
76+
def __enter__(self):
77+
self.pom, self.pom_all = prepare_poms(self.release, self.platform, self.snapshot)
78+
return self
79+
80+
def __exit__(self, *args):
81+
os.remove(self.pom)
82+
os.remove(self.pom_all)
83+
6984

7085
def execute(args: Union[List[str], str]):
7186
subprocess.check_call(args, cwd=CURRENT_DIR, shell=isinstance(args, str), stdout=subprocess.DEVNULL)
@@ -172,11 +187,11 @@ def build_release(release: str):
172187
release_file = f"ap-loader-{release}-{SUB_VERSION}-{platform}-full.jar"
173188
dest_release_file = f"{release_folder}/ap-loader-{release}-{SUB_VERSION}-{platform}.jar"
174189
print(f"Build release for {platform}")
175-
execute(f"mvn -Dproject.vversion={release} -Dproject.subrelease={SUB_VERSION} -Dproject.platform={platform} package assembly:single")
190+
execute(f"mvn -Dproject.vversion={release} -Dproject.subversion={SUB_VERSION} -Dproject.platform={platform} package assembly:single")
176191
shutil.copy(f"{CURRENT_DIR}/target/{release_file}", dest_release_file)
177192
all_target = release_target_file(release, "all")
178193
print("Build release for all")
179-
execute(f"mvn -Dproject.vversion={release} -Dproject.subrelease={SUB_VERSION} -Dproject.platform=all package assembly:single -f pom_all.xml")
194+
execute(f"mvn -Dproject.vversion={release} -Dproject.subversion={SUB_VERSION} -Dproject.platform=all package assembly:single -f pom_all.xml")
180195
shutil.copy(f"{CURRENT_DIR}/target/ap-loader-{release}-{SUB_VERSION}-all-full.jar", all_target)
181196

182197

@@ -293,17 +308,18 @@ def test_release(release: str):
293308

294309
def deploy_maven_platform(release: str, platform: str, snapshot: bool):
295310
print(f"Deploy {release}-{SUB_VERSION} for {platform} to maven")
296-
poms = prepare_poms(release, platform, snapshot)
297-
pom = poms[1] if platform == "all" else poms[0]
298-
cmd = f"mvn -Dproject.vversion={release} -Dproject.subrelease={SUB_VERSION} -Dproject.platform={platform} " \
299-
f"-Dproject.suffix='{'-SNAPSHOT' if snapshot else ''}' -f {pom} clean deploy"
300-
try:
301-
subprocess.check_call(cmd, shell=True, cwd=CURRENT_DIR, stdout=subprocess.DEVNULL,
302-
stderr=subprocess.DEVNULL)
303-
except subprocess.CalledProcessError:
304-
os.system(
305-
f"cd {CURRENT_DIR}; {cmd}")
306-
raise
311+
with PreparedPOMs(release, platform, snapshot) as poms:
312+
pom = poms.pom_all if platform == "all" else poms.pom
313+
cmd = f"mvn -Dproject.vversion={release} -Dproject.subversion={SUB_VERSION} -Dproject.platform={platform} " \
314+
f"-Dproject.suffix='{'-SNAPSHOT' if snapshot else ''}' -f {pom} clean deploy"
315+
try:
316+
subprocess.check_call(cmd, shell=True, cwd=CURRENT_DIR, stdout=subprocess.DEVNULL,
317+
stderr=subprocess.DEVNULL)
318+
#os.system(f"cd {CURRENT_DIR}; {cmd}")
319+
except subprocess.CalledProcessError:
320+
os.system(
321+
f"cd {CURRENT_DIR}; {cmd}")
322+
raise
307323

308324

309325
def deploy_maven(release: str, snapshot: bool = True):

0 commit comments

Comments
 (0)