use of org.infernus.idea.checkstyle.exception.CheckStylePluginException in project checkstyle-idea by jshiell.
the class PluginConfiguration method locationsAreEqual.
private boolean locationsAreEqual(final PluginConfiguration other) {
Iterator<ConfigurationLocation> locationIterator = locations.iterator();
Iterator<ConfigurationLocation> otherLocationIterator = other.locations.iterator();
while (locationIterator.hasNext() && otherLocationIterator.hasNext()) {
try {
if (locationIterator.next().hasChangedFrom(otherLocationIterator.next())) {
return false;
}
} catch (IOException e) {
throw new CheckStylePluginException("Unable to test configuration properties for changes", e);
}
}
return locations.size() == other.locations.size();
}
use of org.infernus.idea.checkstyle.exception.CheckStylePluginException in project checkstyle-idea by jshiell.
the class VersionMixExceptionTest method readBaseVersion.
@NotNull
private static String readBaseVersion() {
String result;
try (InputStream is = VersionMixExceptionTest.class.getResourceAsStream(PROPS_FILE_NAME)) {
Properties props = new Properties();
props.load(is);
result = props.getProperty("baseVersion");
} catch (IOException e) {
throw new CheckStylePluginException("internal error - Failed to read property file: " + PROPS_FILE_NAME, e);
}
Assert.assertNotNull(result);
return result;
}
use of org.infernus.idea.checkstyle.exception.CheckStylePluginException in project checkstyle-idea by jshiell.
the class VersionListReader method readProperties.
@NotNull
private Properties readProperties(@NotNull final String propertyFile) {
final Properties props = new Properties();
InputStream is = null;
try {
is = getClass().getClassLoader().getResourceAsStream(propertyFile);
if (is == null) {
// in unit tests, it seems we need this:
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(propertyFile);
}
if (is != null) {
props.load(is);
}
} catch (IllegalArgumentException | IOException e) {
throw new CheckStylePluginException("Internal error: Could not read internal configuration file '" + propertyFile + "'", e);
} finally {
IOUtils.closeQuietly(is);
}
if (props.isEmpty()) {
throw new CheckStylePluginException("Internal error: Could not read internal configuration file '" + propertyFile + "'");
}
return props;
}
use of org.infernus.idea.checkstyle.exception.CheckStylePluginException in project checkstyle-idea by jshiell.
the class CheckstyleClassLoader method buildClassLoader.
@NotNull
private ClassLoader buildClassLoader(@NotNull final String pClassPathFromProps, @NotNull final List<URL> pThirdPartyClassPath) {
final String basePath = getBasePath();
final File classesDir4UnitTesting = new File(basePath, "classes/java/csaccess");
final boolean unitTesting = classesDir4UnitTesting.exists();
List<URL> urls = new ArrayList<>();
try {
if (unitTesting) {
urls.add(classesDir4UnitTesting.toURI().toURL());
} else {
urls.add(new File(basePath, "checkstyle/classes").toURI().toURL());
}
for (String jar : pClassPathFromProps.trim().split("\\s*;\\s*")) {
if (unitTesting) {
String testJarLocation = "tmp/gatherCheckstyleArtifacts" + jar.substring(jar.lastIndexOf('/'));
urls.add(new File(basePath, testJarLocation).toURI().toURL());
} else {
urls.add(new File(basePath, jar).toURI().toURL());
}
}
} catch (MalformedURLException e) {
throw new CheckStylePluginException("internal error", e);
}
urls.addAll(pThirdPartyClassPath);
// The plugin classloader is the new classloader's parent classloader.
final ChildFirstURLClassLoader newClassLoader = new ChildFirstURLClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader());
if (weAreDebuggingADifferentVersionOfIdea(newClassLoader)) {
// if we're debugging from another version of IDEA then child-first will do nasty things to the IDEA classpath
Notifications.showWarning(project, message("plugin.debugging"));
return new URLClassLoader(urls.toArray(new URL[urls.size()]), getClass().getClassLoader());
}
return newClassLoader;
}
use of org.infernus.idea.checkstyle.exception.CheckStylePluginException in project checkstyle-idea by jshiell.
the class CsVersionInfo method readBaseVersion.
@NotNull
private static String readBaseVersion() {
String result;
try (InputStream is = CsVersionInfo.class.getResourceAsStream(PROPS_FILE_NAME)) {
Properties props = new Properties();
props.load(is);
result = props.getProperty("baseVersion");
} catch (IOException e) {
throw new CheckStylePluginException("internal error - Failed to read property file: " + PROPS_FILE_NAME, e);
}
assertNotNull(result);
return result;
}
Aggregations