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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,33 @@

package org.jsonschema2pojo.util;

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

import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;

import org.apache.commons.lang.StringUtils;
import org.jsonschema2pojo.URLProtocol;
import java.util.Collections;
import java.util.EnumSet;
import java.util.Set;

public class URLUtil {

private static final Set<URLProtocol> LOCAL_PROTOCOL = Collections.unmodifiableSet(EnumSet.of(URLProtocol.NO_PROTOCOL, URLProtocol.FILE));

private URLUtil() {
}

public static boolean isLocalUrl(String input) {
return LOCAL_PROTOCOL.contains(parseProtocol(input));
}

public static boolean isRemoteUrl(String input) {
return !isLocalUrl(input);
}

public static URLProtocol parseProtocol(String input) {
return URLProtocol.fromString(StringUtils.substringBefore(input, ":"));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -819,7 +819,8 @@ public void execute() throws MojoExecutionException {
} else if (!isEmpty(sourcePaths)) {
// verify individual source paths
for (int i = 0; i < sourcePaths.length; i++) {
sourcePaths[i] = FilenameUtils.normalize(sourcePaths[i]);
sourcePaths[i] = URLUtil.isLocalUrl(sourcePaths[i]) ?
FilenameUtils.normalize(sourcePaths[i]) : sourcePaths[i];
try {
URLUtil.parseURL(sourcePaths[i]);
} catch (IllegalArgumentException e) {
Expand Down