|
1 | 1 | package com.codename1.maven; |
2 | 2 |
|
3 | 3 |
|
| 4 | +import org.apache.maven.artifact.Artifact; |
4 | 5 | import org.apache.maven.plugin.MojoExecutionException; |
5 | 6 | import org.apache.maven.plugin.MojoFailureException; |
6 | 7 | import org.apache.maven.plugins.annotations.Execute; |
@@ -77,10 +78,32 @@ private void generateNativeInterface(String relativePath) throws Exception { |
77 | 78 |
|
78 | 79 | if (classFile.exists()) { |
79 | 80 |
|
| 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 |
80 | 88 | 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])); |
84 | 107 | String classPath = relativePath |
85 | 108 | .replace("\\", ".") |
86 | 109 | .replace("/", ".") |
|
0 commit comments