Skip to content

Commit 8c85e5b

Browse files
authored
fix: [3966] generate-native-dependencies fixed for legacy cn1libs (#4097)
Fixed #3966
1 parent 6dd396e commit 8c85e5b

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

maven/codenameone-maven-plugin/src/main/java/com/codename1/maven/GenerateNativeInterfaces.java

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.codename1.maven;
22

33

4+
import org.apache.maven.artifact.Artifact;
45
import org.apache.maven.plugin.MojoExecutionException;
56
import org.apache.maven.plugin.MojoFailureException;
67
import org.apache.maven.plugins.annotations.Execute;
@@ -77,10 +78,32 @@ private void generateNativeInterface(String relativePath) throws Exception {
7778

7879
if (classFile.exists()) {
7980

81+
// Build a comprehensive classpath including all dependencies
82+
List<URL> classpathUrls = new ArrayList<>();
83+
84+
// Add project output directory
85+
classpathUrls.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL());
86+
87+
// Add codenameone-core
8088
File cn1CoreJar = getJar("com.codenameone", "codenameone-core");
81-
URLClassLoader cl = new URLClassLoader(new URL[]{
82-
new File(project.getBuild().getOutputDirectory()).toURI().toURL(),
83-
cn1CoreJar.toURI().toURL()});
89+
if (cn1CoreJar != null) {
90+
classpathUrls.add(cn1CoreJar.toURI().toURL());
91+
}
92+
93+
// Add all project dependencies (including cn1libs with classifiers)
94+
for (Artifact artifact : project.getArtifacts()) {
95+
// Skip provided and test scoped dependencies
96+
if ("provided".equals(artifact.getScope()) || "test".equals(artifact.getScope())) {
97+
continue;
98+
}
99+
100+
File artifactFile = getJar(artifact);
101+
if (artifactFile != null && artifactFile.exists()) {
102+
classpathUrls.add(artifactFile.toURI().toURL());
103+
}
104+
}
105+
106+
URLClassLoader cl = new URLClassLoader(classpathUrls.toArray(new URL[0]));
84107
String classPath = relativePath
85108
.replace("\\", ".")
86109
.replace("/", ".")

0 commit comments

Comments
 (0)