Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing problems with remote URL when using Maven Plugin #1614

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

gr0l
Copy link

@gr0l gr0l commented May 17, 2024

When using remote URL's like an HTTP-Url as sourcePaths input. The URL's have been normalized to a file like notation. Afterwards the type generator was unable to resolve the remote file.


import org.apache.commons.lang.StringUtils;
import org.jsonschema2pojo.URLProtocol;

public class URLUtil {

private static final Set<URLProtocol> LOCAL_PROTOCOL = Arrays.stream(new URLProtocol[]{URLProtocol.NO_PROTOCOL, URLProtocol.FILE}).collect(Collectors.toSet());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this just be replaced by Set.of?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid it can't since Set::of was introduced in Java 9 and current compiler configuration is:

jsonschema2pojo/pom.xml

Lines 213 to 223 in 34cc693

<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
<source>1.8</source>
<target>1.8</target>
<compilerArgs>
<arg>-Xlint</arg>
</compilerArgs>
</configuration>
</plugin>

That being said it could be changed to = EnumSet.of(URLProtocol.NO_PROTOCOL, URLProtocol.FILE) with a small caveat - resulting set would be mutable (however that shouldn't be a problem since it's private and there are no methods returning it's reference.

Copy link
Author

@gr0l gr0l Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed the corresponding line. I am now using an EnumSet wrapped in an unmodifiable set.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants