Skip to content

Commit 63c492c

Browse files
committed
Fix POM related bug
Fixes #3
1 parent 9b9a5b4 commit 63c492c

File tree

4 files changed

+86
-32
lines changed

4 files changed

+86
-32
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,23 @@ You can download the latest release from the
2828
As a shortcut, the wrapper for all platforms can be found
2929
[here](https://github.com/jvm-profiling-tools/ap-loader/releases/latest/download/ap-loader-all.jar).
3030

31-
It should be up to date with the latest async-profiler release, but if not, feel free to create an issue.
31+
It should be up-to-date with the latest async-profiler release, but if not, feel free to create an issue.
3232

33-
To use the library as a dependency, you can depend on `me.bechberger.ap-loader:<version>-<variant>-SNAPSHOT`
33+
To use the library as a dependency, you can depend on `me.bechberger.ap-loader:<version>-<ap-loader-version>-<variant>-SNAPSHOT`
3434
from the [Sonatype OSS repository](https://s01.oss.sonatype.org/content/repositories/snapshots).
35-
See [#usage-in-java-code](Usage in Java Code) for more information.
35+
See [#usage-in-java-code](Usage in Java Code) for more information. The current ap-loader version is `1`.
36+
37+
Or you can depend on the artifacts from maven central, they should be slightly more stable:
38+
39+
```xml
40+
<dependency>
41+
<groupId>me.bechberger</groupId>
42+
<artifactId>ap-loader</artifactId>
43+
<version>2.9-1-all</version>
44+
</dependency>
45+
```
46+
47+
Others are of course available, see [maven central](https://search.maven.org/artifact/me.bechberger/ap-loader).
3648

3749
Supported Platforms
3850
-------------------

bin/releaser.py

Lines changed: 45 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"""
99
import json
1010
import os
11+
import re
1112
import shutil
1213
import subprocess
1314
import sys
@@ -16,6 +17,9 @@
1617
from typing import Any, Dict, List, Union, Tuple, Optional
1718
from urllib import request
1819

20+
SUB_VERSION = 1
21+
RELEASE_NOTES = """- Fixed the library version in the pom #3 (thanks to @gavlyukovskiy for spotting this)"""
22+
1923
HELP = """
2024
Usage:
2125
. python3 releaser.py <command> ... <command> [release or current if not present]
@@ -41,6 +45,28 @@
4145
CACHE_TIME = 60 * 60 * 24 # one day
4246

4347

48+
def prepare_poms(release: str, platform: str, snapshot: bool = True) -> Tuple[str, str]:
49+
""" Prepare the POMs for the given release and platform """
50+
folder = f"{CACHE_DIR}/pom-{release}-{platform}"
51+
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}"
55+
with open(pom_file) as f:
56+
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)
59+
pom_content = re.sub(r"<project.vversion>.*</project.vversion>", f"<project.vversion>{release}</project.vversion>", pom_content, count = 1)
60+
pom_content = re.sub(r"<project.subversion>.*</project.subversion>", f"<project.subversion>{SUB_VERSION}</project.subversion>", pom_content, count = 1)
61+
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}/../..")
64+
with open(dest_pom, "w") as f2:
65+
f2.write(pom_content)
66+
return f"{folder}/pom.xml", f"{folder}/pom_all.xml"
67+
68+
69+
4470
def execute(args: Union[List[str], str]):
4571
subprocess.check_call(args, cwd=CURRENT_DIR, shell=isinstance(args, str), stdout=subprocess.DEVNULL)
4672

@@ -134,7 +160,7 @@ def download_release(release: str):
134160

135161

136162
def release_target_file(release: str, platform: str):
137-
return f"{CURRENT_DIR}/releases/ap-loader-{release}-{platform}.jar"
163+
return f"{CURRENT_DIR}/releases/ap-loader-{release}-{SUB_VERSION}-{platform}.jar"
138164

139165

140166
def build_release(release: str):
@@ -143,15 +169,15 @@ def build_release(release: str):
143169
os.makedirs(release_folder, exist_ok=True)
144170
download_release(release)
145171
for platform in get_release_platforms(release):
146-
release_file = f"ap-loader-{release}-{platform}-full.jar"
147-
dest_release_file = f"{release_folder}/ap-loader-{release}-{platform}.jar"
172+
release_file = f"ap-loader-{release}-{SUB_VERSION}-{platform}-full.jar"
173+
dest_release_file = f"{release_folder}/ap-loader-{release}-{SUB_VERSION}-{platform}.jar"
148174
print(f"Build release for {platform}")
149-
execute(f"mvn -Dproject.versionPlatform={release}-{platform} package assembly:single")
175+
execute(f"mvn -Dproject.vversion={release} -Dproject.subrelease={SUB_VERSION} -Dproject.platform={platform} package assembly:single")
150176
shutil.copy(f"{CURRENT_DIR}/target/{release_file}", dest_release_file)
151177
all_target = release_target_file(release, "all")
152178
print("Build release for all")
153-
execute(f"mvn -Dproject.versionPlatform={release}-all package assembly:single -f pom_all.xml")
154-
shutil.copy(f"{CURRENT_DIR}/target/ap-loader-{release}-all-full.jar", all_target)
179+
execute(f"mvn -Dproject.vversion={release} -Dproject.subrelease={SUB_VERSION} -Dproject.platform=all package assembly:single -f pom_all.xml")
180+
shutil.copy(f"{CURRENT_DIR}/target/ap-loader-{release}-{SUB_VERSION}-all-full.jar", all_target)
155181

156182

157183
def build_tests(release: str):
@@ -266,9 +292,10 @@ def test_release(release: str):
266292

267293

268294
def deploy_maven_platform(release: str, platform: str, snapshot: bool):
269-
print(f"Deploy {release} for {platform} to maven")
270-
pom = "pom_all.xml" if platform == "all" else "pom.xml"
271-
cmd = f"mvn -Dproject.versionPlatform='{release}-{platform}' " \
295+
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} " \
272299
f"-Dproject.suffix='{'-SNAPSHOT' if snapshot else ''}' -f {pom} clean deploy"
273300
try:
274301
subprocess.check_call(cmd, shell=True, cwd=CURRENT_DIR, stdout=subprocess.DEVNULL,
@@ -280,26 +307,27 @@ def deploy_maven_platform(release: str, platform: str, snapshot: bool):
280307

281308

282309
def deploy_maven(release: str, snapshot: bool = True):
283-
print(f"Deploy {release}{' snapshot' if snapshot else ''}")
310+
print(f"Deploy {release}-{SUB_VERSION}{' snapshot' if snapshot else ''}")
284311
for platform in get_release_platforms(release):
285312
deploy_maven_platform(release, platform, snapshot)
286313
deploy_maven_platform(release, "all", snapshot)
287314

288315

289316
def get_changelog(release: str) -> str:
290317
url = get_release(release)["html_url"]
291-
return f"_Copied from the wrapped [async-profiler release]({url}) " \
318+
return f"## ap-loader v{SUB_VERSION}\n\n{RELEASE_NOTES}\n\n" \
319+
f"_The following is copied from the wrapped [async-profiler release]({url}) " \
292320
f"by [Andrei Pangin](https://github.com/apangin). " \
293321
f"The source code linked below should be ignored._\n\n{get_release_info(release)}"
294322

295323

296324
def deploy_github(release: str):
297325
changelog = get_changelog(release)
298326
is_latest = release == get_most_recent_release()
299-
title = f"Loader for {release}: {get_release(release)['name']}"
327+
title = f"Loader for {release} (v{SUB_VERSION}): {get_release(release)['name']}"
300328
prerelease = get_release(release)["prerelease"]
301-
print(f"Deploy {release} ({title}) to GitHub")
302-
if not os.path.exists(f"{CURRENT_DIR}/releases/ap-loader-{release}-all.jar"):
329+
print(f"Deploy {release}-{SUB_VERSION} ({title}) to GitHub")
330+
if not os.path.exists(f"{CURRENT_DIR}/releases/ap-loader-{release}-{SUB_VERSION}-all.jar"):
303331
build_release(release)
304332
with tempfile.TemporaryDirectory() as d:
305333
changelog_file = f"{d}/CHANGELOG.md"
@@ -310,20 +338,20 @@ def deploy_github(release: str):
310338
platform_paths = []
311339
for platform in get_release_platforms(release) + ["all"]:
312340
path = f"{d}/ap-loader-{platform}.jar"
313-
shutil.copy(f"{releases_dir}/ap-loader-{release}-{platform}.jar", path)
341+
shutil.copy(f"{releases_dir}/ap-loader-{release}-{SUB_VERSION}-{platform}.jar", path)
314342
platform_paths.append(path)
315343

316344
flags_str = f"-F {changelog_file} -t '{title}' {'--latest' if is_latest else ''}" \
317345
f" {'--prerelease' if prerelease else ''}"
318346
paths_str = " ".join(f'"{p}"' for p in platform_paths)
319-
cmd = f"gh release create {release} {flags_str} {paths_str}"
347+
cmd = f"gh release create {release}-{SUB_VERSION} {flags_str} {paths_str}"
320348
try:
321349
subprocess.check_call(cmd, shell=True, cwd=CURRENT_DIR, stdout=subprocess.DEVNULL,
322350
stderr=subprocess.DEVNULL)
323351
except subprocess.CalledProcessError:
324352
# this is either a real problem or it means that the release already exists
325353
# in the latter case, we can just update it
326-
cmd = f"gh release edit {release} {flags_str}; gh release upload {release} {paths_str} --clobber"
354+
cmd = f"gh release edit {release}-{SUB_VERSION} {flags_str}; gh release upload {release}-{SUB_VERSION} {paths_str} --clobber"
327355
try:
328356
subprocess.check_call(cmd, shell=True, cwd=CURRENT_DIR, stdout=subprocess.DEVNULL,
329357
stderr=subprocess.DEVNULL)

pom.xml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<name>ap-loader</name>
77
<groupId>me.bechberger</groupId>
88
<artifactId>ap-loader</artifactId>
9-
<version>${project.versionPlatform}${project.suffix}</version>
9+
<version>${project.vversion}-${project.subversion}-${project.platform}${project.suffix}</version>
1010
<url>https://github.com/jvm-profiling-tools/ap-loader</url>
1111
<licenses>
1212
<license>
@@ -33,7 +33,9 @@
3333
<maven.compiler.source>8</maven.compiler.source>
3434
<maven.compiler.target>8</maven.compiler.target>
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36-
<project.versionPlatform>2.8.3-macos</project.versionPlatform>
36+
<project.vversion>2.8.3</project.vversion>
37+
<project.subversion>1</project.subversion>
38+
<project.platform>macos</project.platform>
3739
<project.suffix>-SNAPSHOT</project.suffix>
3840
</properties>
3941

@@ -77,7 +79,7 @@
7779
<arguments>
7880
<argument>${basedir}/bin/copy_libs.sh</argument>
7981
<argument>${basedir}</argument>
80-
<argument>${project.versionPlatform}</argument>
82+
<argument>${project.vversion}-${project.platform}</argument>
8183
</arguments>
8284
<environmentVariables>
8385
<LANG>en_US</LANG>
@@ -109,19 +111,24 @@
109111
<archive>
110112
<manifest>
111113
<addClasspath>true</addClasspath>
112-
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
113-
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
114+
<addDefaultImplementationEntries>false</addDefaultImplementationEntries>
115+
<addDefaultSpecificationEntries>false</addDefaultSpecificationEntries>
114116
<mainClass>one.profiler.AsyncProfilerLoader</mainClass>
115117
</manifest>
116118
<manifestEntries>
117119
<Agent-Class>one.profiler.AsyncProfilerLoader</Agent-Class>
118120
<Premain-Class>one.profiler.AsyncProfilerLoader</Premain-Class>
121+
<Specification-Title>ap-loader</Specification-Title>
122+
<Specification-Version>${project.version}</Specification-Version>
123+
<Implementation-Title>ap-loader</Implementation-Title>
124+
<Implementation-Version>${project.version}</Implementation-Version>
125+
<Implementation-Vendor-Id>me.bechberger</Implementation-Vendor-Id>
119126
</manifestEntries>
120127
</archive>
121128
<descriptorRefs>
122129
<descriptorRef>jar-with-dependencies</descriptorRef>
123130
</descriptorRefs>
124-
<finalName>${project.artifactId}-${project.versionPlatform}-full</finalName>
131+
<finalName>${project.artifactId}-${project.vversion}-${project.subversion}-${project.platform}-full</finalName>
125132
<appendAssemblyId>false</appendAssemblyId>
126133
</configuration>
127134
</plugin>

pom_all.xml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<name>ap-loader</name>
77
<groupId>me.bechberger</groupId>
88
<artifactId>ap-loader</artifactId>
9-
<version>${project.versionPlatform}${project.suffix}</version>
9+
<version>${project.vversion}-${project.subversion}-${project.platform}${project.suffix}</version>
1010
<url>https://github.com/jvm-profiling-tools/ap-loader</url>
1111
<licenses>
1212
<license>
@@ -33,7 +33,9 @@
3333
<maven.compiler.source>8</maven.compiler.source>
3434
<maven.compiler.target>8</maven.compiler.target>
3535
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36-
<project.versionPlatform>2.8.3-all</project.versionPlatform>
36+
<project.vversion>2.8.3</project.vversion>
37+
<project.subversion>1</project.subversion>
38+
<project.platform>all</project.platform>
3739
<project.suffix>-SNAPSHOT</project.suffix>
3840
</properties>
3941

@@ -77,7 +79,7 @@
7779
<arguments>
7880
<argument>${basedir}/bin/copy_all_libs.sh</argument>
7981
<argument>${basedir}</argument>
80-
<argument>${project.versionPlatform}</argument>
82+
<argument>${project.vversion}-${project.platform}</argument>
8183
</arguments>
8284
<environmentVariables>
8385
<LANG>en_US</LANG>
@@ -109,19 +111,24 @@
109111
<archive>
110112
<manifest>
111113
<addClasspath>true</addClasspath>
112-
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
113-
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
114+
<addDefaultImplementationEntries>false</addDefaultImplementationEntries>
115+
<addDefaultSpecificationEntries>false</addDefaultSpecificationEntries>
114116
<mainClass>one.profiler.AsyncProfilerLoader</mainClass>
115117
</manifest>
116118
<manifestEntries>
117119
<Agent-Class>one.profiler.AsyncProfilerLoader</Agent-Class>
118120
<Premain-Class>one.profiler.AsyncProfilerLoader</Premain-Class>
121+
<Specification-Title>ap-loader</Specification-Title>
122+
<Specification-Version>${project.version}</Specification-Version>
123+
<Implementation-Title>ap-loader</Implementation-Title>
124+
<Implementation-Version>${project.version}</Implementation-Version>
125+
<Implementation-Vendor-Id>me.bechberger</Implementation-Vendor-Id>
119126
</manifestEntries>
120127
</archive>
121128
<descriptorRefs>
122129
<descriptorRef>jar-with-dependencies</descriptorRef>
123130
</descriptorRefs>
124-
<finalName>${project.artifactId}-${project.versionPlatform}-full</finalName>
131+
<finalName>${project.artifactId}-${project.vversion}-${project.subversion}-${project.platform}-full</finalName>
125132
<appendAssemblyId>false</appendAssemblyId>
126133
</configuration>
127134
</plugin>

0 commit comments

Comments
 (0)