@@ -111,8 +111,8 @@ public AbstractGraalPyMojo(ProjectBuilder projectBuilder) {
111111 @ Parameter
112112 List <String > packages ;
113113
114- @ Parameter (property = "requirementsFile" )
115- String requirementsFile ;
114+ @ Parameter (property = "requirementsFile" )
115+ String requirementsFile ;
116116
117117 @ SuppressFBWarnings ("UUF_UNUSED_FIELD" )
118118 public static class PythonHome {
@@ -128,7 +128,7 @@ public static class PythonHome {
128128 @ Parameter (defaultValue = "${session}" , readonly = true , required = true )
129129 private MavenSession session ;
130130
131- private final ProjectBuilder projectBuilder ;
131+ private final ProjectBuilder projectBuilder ;
132132
133133 private Set <String > launcherClassPath ;
134134
@@ -152,25 +152,22 @@ protected void listGraalPyResources() throws MojoExecutionException {
152152 }
153153 }
154154
155- protected void preExec (boolean enableWarnings ) throws MojoExecutionException {
156- pythonResourcesDirectory = normalizeEmpty (pythonResourcesDirectory );
157- externalDirectory = normalizeEmpty (externalDirectory );
158- resourceDirectory = normalizeEmpty (resourceDirectory );
159- graalPyLockFile = normalizeEmpty (graalPyLockFile );
160- Path reqFilePath = resolveReqFile ();
161- if (reqFilePath != null ) {
162- getLog ().info ("GraalPy requirements file: " + reqFilePath );
163- if (packages != null ) {
164- throw new MojoExecutionException (
165- "Cannot use <packages> and <requirementsFile> at the same time. "
166- + "New option <requirementsFile> is a replacement for using <packages> with list of inline <package>." );
167- }
168- packages = new ArrayList <>();
169- } else if (packages != null ) {
170- packages = packages .stream ()
171- .filter (p -> p != null && !p .trim ().isEmpty ())
172- .toList ();
173- }
155+ protected void preExec (boolean enableWarnings ) throws MojoExecutionException {
156+ pythonResourcesDirectory = normalizeEmpty (pythonResourcesDirectory );
157+ externalDirectory = normalizeEmpty (externalDirectory );
158+ resourceDirectory = normalizeEmpty (resourceDirectory );
159+ graalPyLockFile = normalizeEmpty (graalPyLockFile );
160+ Path reqFilePath = resolveReqFile ();
161+ if (reqFilePath != null ) {
162+ getLog ().info ("GraalPy requirements file: " + reqFilePath );
163+ if (packages != null ) {
164+ throw new MojoExecutionException ("Cannot use <packages> and <requirementsFile> at the same time. "
165+ + "New option <requirementsFile> is a replacement for using <packages> with list of inline <package>." );
166+ }
167+ packages = new ArrayList <>();
168+ } else if (packages != null ) {
169+ packages = packages .stream ().filter (p -> p != null && !p .trim ().isEmpty ()).toList ();
170+ }
174171
175172 if (pythonResourcesDirectory != null ) {
176173 if (externalDirectory != null ) {
@@ -216,27 +213,23 @@ protected void preExec(boolean enableWarnings) throws MojoExecutionException {
216213 }
217214 }
218215
219- protected Path resolveReqFile () throws MojoExecutionException {
220- if (requirementsFile == null || requirementsFile .isBlank ()) {
221- return null ;
222- }
216+ protected Path resolveReqFile () throws MojoExecutionException {
217+ if (requirementsFile == null || requirementsFile .isBlank ()) {
218+ return null ;
219+ }
223220
224- Path path = Path .of (requirementsFile );
225- Path finalPath = path .isAbsolute ()
226- ? path
227- : project .getBasedir ().toPath ().resolve (path ).normalize ();
221+ Path path = Path .of (requirementsFile );
222+ Path finalPath = path .isAbsolute () ? path : project .getBasedir ().toPath ().resolve (path ).normalize ();
228223
229- if (!Files .exists (finalPath )) {
230- throw new MojoExecutionException (
231- "The configured requirementsFile does not exist: " + finalPath
232- + "\n Please provide a valid path to a pip-compatible requirements file."
233- );
234- }
224+ if (!Files .exists (finalPath )) {
225+ throw new MojoExecutionException ("The configured requirementsFile does not exist: " + finalPath
226+ + "\n Please provide a valid path to a pip-compatible requirements file." );
227+ }
235228
236- return finalPath ;
237- }
229+ return finalPath ;
230+ }
238231
239- protected void postExec () throws MojoExecutionException {
232+ protected void postExec () throws MojoExecutionException {
240233 for (Resource r : project .getBuild ().getResources ()) {
241234 if (Files .exists (Path .of (r .getDirectory (), resourceDirectory , "proj" ))) {
242235 getLog ().warn (String .format ("usage of %s is deprecated, use %s instead" ,
@@ -284,11 +277,11 @@ private static String normalizeEmpty(String s) {
284277 }
285278
286279 protected Launcher createLauncher () {
287- return new Launcher (getLauncherPath ()) {
288- public Set <String > computeClassPath () throws IOException {
289- return calculateLauncherClasspath (project );
290- }
291- };
280+ return new Launcher (getLauncherPath ()) {
281+ public Set <String > computeClassPath () throws IOException {
282+ return calculateLauncherClasspath (project );
283+ }
284+ };
292285 }
293286
294287 protected Path getLockFile () {
@@ -327,7 +320,8 @@ protected static String getGraalPyVersion(MavenProject project) throws IOExcepti
327320
328321 private static Artifact getGraalPyArtifact (MavenProject project ) throws IOException {
329322 var projectArtifacts = resolveProjectDependencies (project );
330- Artifact graalPyArtifact = projectArtifacts .stream ().filter (AbstractGraalPyMojo ::isPythonArtifact ).findFirst ().orElse (null );
323+ Artifact graalPyArtifact = projectArtifacts .stream ().filter (AbstractGraalPyMojo ::isPythonArtifact ).findFirst ()
324+ .orElse (null );
331325 return Optional .ofNullable (graalPyArtifact ).orElseThrow (() -> new IOException (
332326 "Missing GraalPy dependency. Please add to your pom either %s:%s or %s:%s" .formatted (POLYGLOT_GROUP_ID ,
333327 PYTHON_COMMUNITY_ARTIFACT_ID , POLYGLOT_GROUP_ID , PYTHON_ARTIFACT_ID )));
@@ -360,7 +354,7 @@ private Set<String> calculateLauncherClasspath(MavenProject project) throws IOEx
360354 && PYTHON_LAUNCHER_ARTIFACT_ID .equals (a .getArtifactId ()))
361355 .findFirst ().orElse (null );
362356 // python-launcher artifact
363- assert graalPyLauncherArtifact != null ;
357+ assert graalPyLauncherArtifact != null ;
364358 launcherClassPath .add (graalPyLauncherArtifact .getFile ().getAbsolutePath ());
365359 // and transitively all its dependencies
366360 launcherClassPath .addAll (resolveDependencies (graalPyLauncherArtifact ));
0 commit comments