Skip to content

Commit c025031

Browse files
committed
chore: apply Spotless formatting after mvnw validate
1 parent 21915dc commit c025031

File tree

6 files changed

+327
-328
lines changed

6 files changed

+327
-328
lines changed

graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/AbstractGraalPyMojo.java

Lines changed: 40 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -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-
+ "\nPlease 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+
+ "\nPlease 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));

graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/InstallPackagesMojo.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ private void manageVenv() throws MojoExecutionException {
9999
Path venvDirectory = getVenvDirectory();
100100
MavenDelegateLog log = new MavenDelegateLog(getLog());
101101
Path lockFile = getLockFile();
102-
Path reqFile = resolveReqFile();
102+
Path reqFile = resolveReqFile();
103103
try {
104104
VFSUtils.createVenv(venvDirectory, packages, lockFile, MISSING_LOCK_FILE_WARNING, createLauncher(),
105105
getGraalPyVersion(project), log, reqFile);

graalpy-maven-plugin/src/main/java/org/graalvm/python/maven/plugin/LockPackagesMojo.java

Lines changed: 57 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -64,50 +64,49 @@ public class LockPackagesMojo extends AbstractGraalPyMojo {
6464
This file contains a list of all required Python packages with their specific versions,
6565
based on the packages defined in the plugin configuration and their dependencies.
6666
""";
67-
public static final String MISSING_DEPENDENCY_CONFIGURATION_ERROR = """
68-
In order to run the lock-packages goal you must declare Python dependencies in the graalpy-maven-plugin configuration.
69-
70-
You must configure Python dependencies in one of the following ways:
71-
72-
Option 1: Use <packages> with inline versioned package entries:
73-
74-
<plugin>
75-
<groupId>org.graalvm.python</groupId>
76-
<artifactId>graalpy-maven-plugin</artifactId>
77-
<configuration>
78-
<packages>
79-
<package>{package_name}=={package_version}</package>
80-
</packages>
81-
...
82-
</configuration>
83-
</plugin>
84-
85-
Option 2: Use a pip-compatible requirements.txt file:
86-
87-
<plugin>
88-
<groupId>org.graalvm.python</groupId>
89-
<artifactId>graalpy-maven-plugin</artifactId>
90-
<configuration>
91-
<requirementsFile>requirements.txt</requirementsFile>
92-
...
93-
</configuration>
94-
</plugin>
95-
96-
IMPORTANT:
97-
• The requirementsFile workflow follows pip's native behavior.
98-
• GraalPy lock files are NOT used or generated when requirementsFile is specified.
99-
• The 'lock-packages' goal is NOT supported with <requirementsFile>.
100-
• Users are expected to manage locking / freezing themselves using pip conventions (e.g., pip freeze).
101-
• Do not define both <packages> and <requirementsFile> at the same time.
102-
• The <configuration> section must be declared on the graalpy-maven-plugin itself,
103-
not inside a specific execution.
104-
105-
For more details, see:
106-
https://github.com/oracle/graalpython/blob/master/docs/user/Embedding-Build-Tools.md
107-
""";
108-
109-
110-
@Inject
67+
public static final String MISSING_DEPENDENCY_CONFIGURATION_ERROR = """
68+
In order to run the lock-packages goal you must declare Python dependencies in the graalpy-maven-plugin configuration.
69+
70+
You must configure Python dependencies in one of the following ways:
71+
72+
Option 1: Use <packages> with inline versioned package entries:
73+
74+
<plugin>
75+
<groupId>org.graalvm.python</groupId>
76+
<artifactId>graalpy-maven-plugin</artifactId>
77+
<configuration>
78+
<packages>
79+
<package>{package_name}=={package_version}</package>
80+
</packages>
81+
...
82+
</configuration>
83+
</plugin>
84+
85+
Option 2: Use a pip-compatible requirements.txt file:
86+
87+
<plugin>
88+
<groupId>org.graalvm.python</groupId>
89+
<artifactId>graalpy-maven-plugin</artifactId>
90+
<configuration>
91+
<requirementsFile>requirements.txt</requirementsFile>
92+
...
93+
</configuration>
94+
</plugin>
95+
96+
IMPORTANT:
97+
• The requirementsFile workflow follows pip's native behavior.
98+
• GraalPy lock files are NOT used or generated when requirementsFile is specified.
99+
• The 'lock-packages' goal is NOT supported with <requirementsFile>.
100+
• Users are expected to manage locking / freezing themselves using pip conventions (e.g., pip freeze).
101+
• Do not define both <packages> and <requirementsFile> at the same time.
102+
• The <configuration> section must be declared on the graalpy-maven-plugin itself,
103+
not inside a specific execution.
104+
105+
For more details, see:
106+
https://github.com/oracle/graalpython/blob/master/docs/user/Embedding-Build-Tools.md
107+
""";
108+
109+
@Inject
111110
public LockPackagesMojo(ProjectBuilder projectBuilder) {
112111
super(projectBuilder);
113112
}
@@ -135,18 +134,18 @@ protected void manageVenv() throws MojoExecutionException {
135134
}
136135
}
137136

138-
private void checkEmptyPackages() throws MojoExecutionException {
139-
Path reqFilePath = resolveReqFile();
140-
boolean emptyPackages = packages == null || packages.isEmpty();
141-
boolean requirementsExists = reqFilePath != null;
142-
// Disallow lock-packages when no packages OR when requirementsFile is used
143-
if (emptyPackages || requirementsExists) {
144-
getLog().error("");
145-
getLog().error("Missing Python dependency configuration.");
146-
getLog().error("");
147-
getLog().error(MISSING_DEPENDENCY_CONFIGURATION_ERROR);
148-
getLog().error("");
149-
throw new MojoExecutionException("Missing Python dependency configuration.");
150-
}
151-
}
137+
private void checkEmptyPackages() throws MojoExecutionException {
138+
Path reqFilePath = resolveReqFile();
139+
boolean emptyPackages = packages == null || packages.isEmpty();
140+
boolean requirementsExists = reqFilePath != null;
141+
// Disallow lock-packages when no packages OR when requirementsFile is used
142+
if (emptyPackages || requirementsExists) {
143+
getLog().error("");
144+
getLog().error("Missing Python dependency configuration.");
145+
getLog().error("");
146+
getLog().error(MISSING_DEPENDENCY_CONFIGURATION_ERROR);
147+
getLog().error("");
148+
throw new MojoExecutionException("Missing Python dependency configuration.");
149+
}
150+
}
152151
}

0 commit comments

Comments
 (0)