1
1
/*
2
- * Copyright (c) 2019, 2023 , Gluon
2
+ * Copyright (c) 2019, 2024 , Gluon
3
3
* All rights reserved.
4
4
*
5
5
* Redistribution and use in source and binary forms, with or without
36
36
import com .gluonhq .substrate .SubstrateDispatcher ;
37
37
import com .gluonhq .substrate .model .Triplet ;
38
38
import com .gluonhq .substrate .target .WebTargetConfiguration ;
39
- import com .gluonhq .substrate .util .Version ;
40
39
import com .gluonhq .utils .MavenArtifactResolver ;
41
40
import org .apache .commons .exec .ProcessDestroyer ;
42
41
import org .apache .commons .exec .ShutdownHookProcessDestroyer ;
43
42
import org .apache .maven .artifact .Artifact ;
44
43
import org .apache .maven .execution .MavenSession ;
45
44
import org .apache .maven .model .Dependency ;
46
- import org .apache .maven .model .Repository ;
47
45
import org .apache .maven .plugin .AbstractMojo ;
48
46
import org .apache .maven .plugin .BuildPluginManager ;
49
47
import org .apache .maven .plugin .MojoExecutionException ;
50
48
import org .apache .maven .plugins .annotations .Component ;
51
49
import org .apache .maven .plugins .annotations .Parameter ;
52
50
import org .apache .maven .project .MavenProject ;
53
51
import org .apache .maven .rtinfo .RuntimeInformation ;
52
+ import org .eclipse .aether .RepositorySystem ;
53
+ import org .eclipse .aether .RepositorySystemSession ;
54
54
import org .eclipse .aether .artifact .DefaultArtifact ;
55
55
import org .eclipse .aether .graph .DependencyFilter ;
56
+ import org .eclipse .aether .repository .RemoteRepository ;
56
57
57
58
import java .io .File ;
58
59
import java .io .IOException ;
@@ -74,14 +75,29 @@ public abstract class NativeBaseMojo extends AbstractMojo {
74
75
75
76
private static final List <String > ALLOWED_DEPENDENCY_TYPES = Collections .singletonList ("jar" );
76
77
77
- // TODO: Remove this restriction when MavenArtifactResolver works with Maven 3.9.0+
78
- private static final Version MAX_SUPPORTED_MAVEN_VERSION = new Version (3 , 8 , 8 );
79
-
80
78
Path outputDir ;
81
79
82
80
@ Parameter (defaultValue = "${project}" , readonly = true )
83
81
MavenProject project ;
84
82
83
+ /**
84
+ * The entry point to Maven Artifact Resolver
85
+ */
86
+ @ Component
87
+ private RepositorySystem repoSystem ;
88
+
89
+ /**
90
+ * The current repository/network configuration of Maven.
91
+ */
92
+ @ Parameter (defaultValue = "${repositorySystemSession}" , readonly = true )
93
+ private RepositorySystemSession repoSession ;
94
+
95
+ /**
96
+ * The project's remote repositories to use for the resolution.
97
+ */
98
+ @ Parameter (defaultValue = "${project.remoteProjectRepositories}" , readonly = true )
99
+ private List <RemoteRepository > remoteRepos ;
100
+
85
101
@ Parameter (defaultValue = "${session}" , readonly = true )
86
102
MavenSession session ;
87
103
@@ -157,12 +173,6 @@ public abstract class NativeBaseMojo extends AbstractMojo {
157
173
private ProcessDestroyer processDestroyer ;
158
174
159
175
public SubstrateDispatcher createSubstrateDispatcher () throws IOException , MojoExecutionException {
160
- String mavenVersion = runtimeInformation .getMavenVersion ();
161
- Version version = new Version (mavenVersion );
162
- if (version .compareTo (MAX_SUPPORTED_MAVEN_VERSION ) > 0 ) {
163
- throw new MojoExecutionException ("Maven version " + mavenVersion + " is not currently supported by the GluonFX Maven Plugin.\n " +
164
- "Please downgrade your Maven version to " + MAX_SUPPORTED_MAVEN_VERSION + " and then try again.\n " );
165
- }
166
176
if (getGraalvmHome ().isEmpty ()) {
167
177
throw new MojoExecutionException ("GraalVM installation directory not found." +
168
178
" Either set GRAALVM_HOME as an environment variable or" +
@@ -242,12 +252,7 @@ private String getProjectClasspath() {
242
252
}
243
253
244
254
private List <File > getClasspathElements (MavenProject project ) {
245
- List <Repository > repositories = project .getRepositories ();
246
- Repository gluonRepository = new Repository ();
247
- gluonRepository .setId ("Gluon" );
248
- gluonRepository .setUrl ("https://nexus.gluonhq.com/nexus/content/repositories/releases" );
249
- repositories .add (gluonRepository );
250
- MavenArtifactResolver .initRepositories (repositories );
255
+ MavenArtifactResolver .initRepositories (repoSystem , repoSession , remoteRepos );
251
256
252
257
List <Artifact > attachDependencies = getAttachDependencies ();
253
258
List <File > list = Stream .concat (project .getArtifacts ().stream (), attachDependencies .stream ())
0 commit comments