multi-binding types (shared/static) - shared preferred method is overwritten by addition of static
GregDomjan opened this issue · 1 comments
Nar detail for output multi-binding types (shared/static) - shared preferred method is overwritten by addition of static
nar-maven-plugin/src/main/java/com/github/maven_nar/NarLayout21.java
Lines 238 to 243 in 2c3442e
adding amd64 shared
libs.binding=shared
amd64-Windows-msvc.libs.binding=shared
then adding amd64 static overrides
libs.binding=static
amd64-Windows-msvc.libs.binding=static
then adding x86 shared
x86-Windows-msvc.libs.binding=shared
libs.binding=shared
amd64-Windows-msvc.libs.binding=static
then finally adding x86 static
x86-Windows-msvc.libs.binding=static
libs.binding=static
amd64-Windows-msvc.libs.binding=static
I seem to have run into this problem (or a closely related one)
[Some edits made to obscure some things but the gist of all aspects remain intact]
Consider the following output:
[INFO] --- nar-maven-plugin:3.10.1:nar-unpack (default-nar-unpack) @ xyz ---
[INFO] Getting Nar dependencies
[INFO] Unpacking 2 dependencies to /home/mixed/target/nar
[INFO] + ranlib /home/mixed/target/nar/cache-0.0-SNAPSHOT-amd64-Linux-gcc-static/lib/amd64-Linux-gcc/static/libcache-0.0-SNAPSHOT.a
Given the following pom entry to try and force the issue:
<dependencies>
<dependency>
<groupId>xyz</groupId>
<artifactId>cache</artifactId>
<version>0.0-SNAPSHOT</version>
<type>nar</type>
<classifier>amd64-Linux-gcc-shared</classifier> <-----
</dependency>
</dependencies>
Why is NAR resolving to unpacking the STATIC version of libcache when there's a SHARED version in the maven repository produced via the following plugin config:
<libraries>
<library>
<type>shared</type>
</library>
<library>
<type>static</type>
</library>
</libraries>
Here's the debug output showing the resolution path:
[INFO] --- nar-maven-plugin:3.10.1:nar-download (default-nar-download) @ xyz ---
[DEBUG] Configuring mojo com.github.maven-nar:nar-maven-plugin:3.10.1:nar-download from plugin realm ClassRealm[extension>com.github.maven-nar:nar-maven-plugin:3.10.1, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@55054057]
[DEBUG] Configuring mojo 'com.github.maven-nar:nar-maven-plugin:3.10.1:nar-download' with basic configurator -->
[DEBUG] (f) architecture = amd64
[DEBUG] (f) baseDir = /home/mixed
[DEBUG] (f) classesDirectory = /home/mixed/target/classes
[DEBUG] (f) dryRun = false
[DEBUG] (f) ignore = false
[DEBUG] (f) includesType = local
[DEBUG] (f) layout = com.github.maven_nar.NarLayout21
[DEBUG] (f) type = shared
[DEBUG] (f) libraries = [Library: type: shared]
[DEBUG] (f) name = gcc
[DEBUG] (f) options = []
[DEBUG] (f) linker = com.github.maven_nar.Linker@76e3b45b
[DEBUG] (f) localRepository = id: local
url: file:///home/mixed/.m2/repository/
layout: default
snapshots: [enabled => true, update => always]
releases: [enabled => true, update => always]
[DEBUG] (f) mavenProject = MavenProject: xyz:0.0-SNAPSHOT @ /home/mixed/pom.xml
[DEBUG] (f) os = Linux
[DEBUG] (f) outputDirectory = /home/mixed/target
[DEBUG] (f) projectRepos = [central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG] (f) remoteArtifactRepositories = [ id: central
url: https://repo.maven.apache.org/maven2
layout: default
snapshots: [enabled => false, update => daily]
releases: [enabled => true, update => daily]
]
[DEBUG] (f) repoSession = org.eclipse.aether.DefaultRepositorySystemSession@25ad4f71
[DEBUG] (f) skip = false
[DEBUG] (f) skipRanlib = false
[DEBUG] -- end configuration --
[DEBUG] linker original name: gcc
[DEBUG] aol_linker: gcc
[INFO] Getting Nar dependencies
[DEBUG] Examining artifact for NarInfo: cache:nar:amd64-Linux-gcc-shared:0.0-SNAPSHOT:compile
[DEBUG] - added as NarDependency
[DEBUG] Dependencies contained 1 NAR artifacts.
[DEBUG] getProperty(amd64-Linux-gcc, libs.binding, static) = static
[DEBUG] GetNarDependencies for cache:nar:amd64-Linux-gcc-shared:0.0-SNAPSHOT:compile, aol: amd64-Linux-gcc, type: static
[DEBUG] getProperty(amd64-Linux-gcc, nar.static, null) = cache:nar:${aol}-static
[DEBUG] Checking: cache:nar:${aol}-static
[DEBUG] getProperty(amd64-Linux-gcc, amd64-Linux-gcc, amd64-Linux-gcc) = amd64-Linux-gcc
[DEBUG] GetNarDependencies for cache:nar:amd64-Linux-gcc-shared:0.0-SNAPSHOT:compile, aol: null, type: noarch
[DEBUG] getProperty(null, nar.noarch, null) = cache:nar:noarch
[DEBUG] Checking: cache:nar:noarch
[INFO] Getting Nar dependencies
[DEBUG] getProperty(amd64-Linux-gcc, libs.binding, static) = static
[DEBUG] GetNarDependencies for cache:nar:amd64-Linux-gcc-shared:0.0-SNAPSHOT:compile, aol: amd64-Linux-gcc, type: static
[DEBUG] getProperty(amd64-Linux-gcc, nar.static, null) = cache:nar:${aol}-static
[DEBUG] Checking: cache:nar:${aol}-static
[DEBUG] getProperty(amd64-Linux-gcc, amd64-Linux-gcc, amd64-Linux-gcc) = amd64-Linux-gcc
[DEBUG] GetNarDependencies for cache:nar:amd64-Linux-gcc-shared:0.0-SNAPSHOT:compile, aol: null, type: noarch
[DEBUG] getProperty(null, nar.noarch, null) = cache:nar:noarch
[DEBUG] Checking: cache:nar:noarch
[DEBUG] Download for NarDependencies {
[DEBUG] - cache:nar:amd64-Linux-gcc-static:0.0-SNAPSHOT:compile
[DEBUG] - cache:nar:noarch:0.0-SNAPSHOT:compile
[DEBUG] - cache:nar:amd64-Linux-gcc-static:0.0-SNAPSHOT:compile
[DEBUG] - cache:nar:noarch:0.0-SNAPSHOT:compile
[DEBUG] }
[DEBUG] Resolving cache:nar:amd64-Linux-gcc-static:0.0-SNAPSHOT:compile
[DEBUG] Resolving cache:nar:noarch:0.0-SNAPSHOT:compile
[DEBUG] Resolving cache:nar:amd64-Linux-gcc-static:0.0-SNAPSHOT:compile
[DEBUG] Resolving cache:nar:noarch:0.0-SNAPSHOT:compile
[INFO]
[INFO] --- nar-maven-plugin:3.10.1:nar-unpack (default-nar-unpack) @ xyz ---
[DEBUG] Configuring mojo com.github.maven-nar:nar-maven-plugin:3.10.1:nar-unpack from plugin realm ClassRealm[extension>com.github.maven-nar:nar-maven-plugin:3.10.1, parent: jdk.internal.loader.ClassLoaders$AppClassLoader@55054057]
[DEBUG] Configuring mojo 'com.github.maven-nar:nar-maven-plugin:3.10.1:nar-unpack' with basic configurator -->
[DEBUG] (f) architecture = amd64
[DEBUG] (f) baseDir = /home/mixed
[DEBUG] (f) classesDirectory = /home/mixed/target/classes
[DEBUG] (f) dryRun = false
[DEBUG] (f) ignore = false
[DEBUG] (f) includesType = local
[DEBUG] (f) layout = com.github.maven_nar.NarLayout21
[DEBUG] (f) type = shared
[DEBUG] (f) libraries = [Library: type: shared]
[DEBUG] (f) name = gcc
[DEBUG] (f) options = []
[DEBUG] (f) linker = com.github.maven_nar.Linker@69909c14
[DEBUG] (f) localRepository = id: local
url: file:///home/mixed/.m2/repository/
layout: default
snapshots: [enabled => true, update => always]
releases: [enabled => true, update => always]
[DEBUG] (f) mavenProject = MavenProject: xyz:0.0-SNAPSHOT @ /home/mixed/pom.xml
[DEBUG] (f) os = Linux
[DEBUG] (f) outputDirectory = /home/mixed/target
[DEBUG] (f) projectRepos = [central (https://repo.maven.apache.org/maven2, default, releases)]
[DEBUG] (f) remoteArtifactRepositories = [ id: central
url: https://repo.maven.apache.org/maven2
layout: default
snapshots: [enabled => false, update => daily]
releases: [enabled => true, update => daily]
]
[DEBUG] (f) repoSession = org.eclipse.aether.DefaultRepositorySystemSession@25ad4f71
[DEBUG] (f) skip = false
[DEBUG] (f) skipRanlib = false
[DEBUG] -- end configuration --
[DEBUG] linker original name: gcc
[DEBUG] aol_linker: gcc
[INFO] Getting Nar dependencies
[DEBUG] Examining artifact for NarInfo: cache:nar:amd64-Linux-gcc-shared:0.0-SNAPSHOT:compile
[DEBUG] - added as NarDependency
[DEBUG] Dependencies contained 1 NAR artifacts.
[DEBUG] getProperty(amd64-Linux-gcc, libs.binding, static) = static
[DEBUG] GetNarDependencies for cache:nar:amd64-Linux-gcc-shared:0.0-SNAPSHOT:compile, aol: amd64-Linux-gcc, type: static
[DEBUG] getProperty(amd64-Linux-gcc, nar.static, null) = cache:nar:${aol}-static
[DEBUG] Checking: cache:nar:${aol}-static
[DEBUG] getProperty(amd64-Linux-gcc, amd64-Linux-gcc, amd64-Linux-gcc) = amd64-Linux-gcc
[DEBUG] GetNarDependencies for cache:nar:amd64-Linux-gcc-shared:0.0-SNAPSHOT:compile, aol: null, type: noarch
[DEBUG] getProperty(null, nar.noarch, null) = cache:nar:noarch
[DEBUG] Checking: cache:nar:noarch
[INFO] Unpacking 2 dependencies to /home/mixed/target/nar
[DEBUG] linker original name: gcc
[DEBUG] aol_linker: gcc
[DEBUG] Unpack cache:nar:amd64-Linux-gcc-static:0.0-SNAPSHOT:compile (/home/mixed/.m2/repository/cache/0.0-SNAPSHOT/cache-0.0-SNAPSHOT-amd64-Linux-gcc-static.nar) to /home/mixed/target/nar
[DEBUG] Using com.github.maven_nar.NarLayout21
[DEBUG] Expanding: /home/mixed/.m2/repository/cache/0.0-SNAPSHOT/cache-0.0-SNAPSHOT-amd64-Linux-gcc-static.nar into /home/mixed/target/nar/cache-0.0-SNAPSHOT-amd64-Linux-gcc-static
[DEBUG] expand complete
[INFO] + ranlib /home/mixed/target/nar/cache-0.0-SNAPSHOT-amd64-Linux-gcc-static/lib/amd64-Linux-gcc/static/libcache-0.0-SNAPSHOT.a
[DEBUG] RunCommand: ranlib
[DEBUG] '/home/mixed/target/nar/cache-0.0-SNAPSHOT-amd64-Linux-gcc-static/lib/amd64-Linux-gcc/static/libcache-0.0-SNAPSHOT.a'
[DEBUG] ExitValue: 0
[DEBUG] linker original name: gcc
[DEBUG] aol_linker: gcc
[DEBUG] Unpack cache:nar:noarch:0.0-SNAPSHOT:compile (/home/mixed/.m2/repository/cache/0.0-SNAPSHOT/cache-0.0-SNAPSHOT-noarch.nar) to /home/mixed/target/nar
[DEBUG] Expanding: /home/mixed/.m2/repository/cache/0.0-SNAPSHOT/cache-0.0-SNAPSHOT-noarch.nar into /home/mixed/target/nar/cache-0.0-SNAPSHOT-noarch
[DEBUG] expand complete
Sure enough the nar.properties in the SHARED lib artifact looks as follows:
#NAR Properties for cache-0.0-SNAPSHOT
includes.type=local
output=cache-0.0-SNAPSHOT
nar.shared=cache\:nar\:${aol}-shared
nar.static=cache\:nar\:${aol}-static
nar.noarch=cache\:nar\:noarch
amd64-Linux-gcc.output=cache-0.0-SNAPSHOT
libs.binding=static
amd64-Linux-gcc.libs.binding=static
Any way to resolve this temporarily via Config or CLI options?
Of course by manually exploding the SHARED lib nar and changing the last two *.libs.binding entries to "shared", the xyz project is able to pick up the correct SHARED lib when the -shared classifier is specified in its pom.xml depedency section.
Without the classifier xyz pulls in the STATIC lib.