mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-216217 - fixed issue when settings.xml do not have schema
GitOrigin-RevId: c7a8cec9b6417a6fb4352ee4f2e79963a374707d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0e5854e49b
commit
e45fcfc2de
@@ -49,6 +49,7 @@ import com.intellij.util.xml.NanoXmlUtil;
|
||||
import gnu.trove.THashSet;
|
||||
import icons.MavenIcons;
|
||||
import org.jdom.Element;
|
||||
import org.jdom.JDOMException;
|
||||
import org.jdom.Namespace;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -743,11 +744,7 @@ public class MavenUtil {
|
||||
@Nullable
|
||||
public static String getRepositoryFromSettings(final File file) {
|
||||
try {
|
||||
Element fileElement = JDOMUtil.load(file);
|
||||
Element repository = fileElement.getChild("localRepository");
|
||||
if (repository == null) {
|
||||
repository = fileElement.getChild("localRepository", Namespace.getNamespace("http://maven.apache.org/SETTINGS/1.0.0"));
|
||||
}
|
||||
Element repository = getRepositoryElement(file);
|
||||
|
||||
if (repository == null) {
|
||||
return null;
|
||||
@@ -763,6 +760,19 @@ public class MavenUtil {
|
||||
}
|
||||
}
|
||||
|
||||
private static Element getRepositoryElement(File file) throws JDOMException, IOException {
|
||||
Element fileElement = JDOMUtil.load(file);
|
||||
|
||||
Element repository = fileElement.getChild("localRepository");
|
||||
if (repository == null) {
|
||||
repository = fileElement.getChild("localRepository", Namespace.getNamespace("http://maven.apache.org/SETTINGS/1.0.0"));
|
||||
}
|
||||
if (repository == null) {
|
||||
repository = fileElement.getChild("localRepository", Namespace.getNamespace("http://maven.apache.org/SETTINGS/1.1.0"));
|
||||
}
|
||||
return repository;
|
||||
}
|
||||
|
||||
public static String expandProperties(String text, Properties props) {
|
||||
if (StringUtil.isEmptyOrSpaces(text)) return text;
|
||||
for (Map.Entry<Object, Object> each : props.entrySet()) {
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.io.IOException;
|
||||
|
||||
public class MavenUtilTest extends MavenTestCase {
|
||||
|
||||
public void testFindLocalRepo() throws IOException {
|
||||
public void testFindLocalRepoSchema10() throws IOException {
|
||||
VirtualFile file = createProjectSubFile("testsettings.xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||
"<settings xmlns=\"http://maven.apache.org/SETTINGS/1.0.0\"\n" +
|
||||
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
|
||||
@@ -19,6 +19,16 @@ public class MavenUtilTest extends MavenTestCase {
|
||||
assertEquals("mytestpath", MavenUtil.getRepositoryFromSettings(new File(file.getPath())));
|
||||
}
|
||||
|
||||
public void testFindLocalRepoSchema11() throws IOException {
|
||||
VirtualFile file = createProjectSubFile("testsettings.xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||
"<settings xsi:schemaLocation=\"http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd\"\n" +
|
||||
" xmlns=\"http://maven.apache.org/SETTINGS/1.1.0\"\n" +
|
||||
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
|
||||
" <localRepository>mytestpath</localRepository>" +
|
||||
"</settings>");
|
||||
assertEquals("mytestpath", MavenUtil.getRepositoryFromSettings(new File(file.getPath())));
|
||||
}
|
||||
|
||||
public void testFindLocalRepoWithoutXmls() throws IOException {
|
||||
VirtualFile file = createProjectSubFile("testsettings.xml", "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
|
||||
"<settings>" +
|
||||
|
||||
Reference in New Issue
Block a user