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

Enable running Launcher from IntelliJ #635

Closed
wants to merge 2 commits into from
Closed
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 @@ -27,7 +27,7 @@ public static JournalAbbreviationRepository loadRepository(JournalAbbreviationPr
try {
Path tempDir = Files.createTempDirectory("jabref-journal");
Path tempJournalList = tempDir.resolve("journalList.mv");
Files.copy(JournalAbbreviationRepository.class.getResourceAsStream("/journals/journalList.mv"), tempJournalList);
Files.copy(JournalAbbreviationRepository.class.getClassLoader().getResourceAsStream("journals/journalList.mv"), tempJournalList);
repository = new JournalAbbreviationRepository(tempJournalList);
tempDir.toFile().deleteOnExit();
tempJournalList.toFile().deleteOnExit();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public X509Certificate getCertificate(String alias) {
public static void createTruststoreFileIfNotExist(Path storePath) {
try {
LOGGER.debug("Trust store path: {}", storePath.toAbsolutePath());
Path storeResourcePath = Path.of(TrustStoreManager.class.getResource("/ssl/truststore.jks").toURI());
Path storeResourcePath = Path.of(TrustStoreManager.class.getClassLoader().getResource("ssl/truststore.jks").toURI());
Files.createDirectories(storePath.getParent());
if (Files.notExists(storePath)) {
Files.copy(storeResourcePath, storePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,14 @@ public class ProtectedTermsParser {
private String location;

public void readTermsFromResource(String resourceFileName, String descriptionString) {
URL url = Objects
.requireNonNull(ProtectedTermsLoader.class.getResource(Objects.requireNonNull(resourceFileName)));
URL resource = ProtectedTermsLoader.class.getResource(Objects.requireNonNull(resourceFileName));
if (Objects.isNull(resource)) {
// Workaround for the case when using IntelliJ
// input resourceFileName starts with a "/"
// When using "getClassLoader()", the "/" must not be used
resource = ProtectedTermsParser.class.getClassLoader().getResource(resourceFileName.substring(1));
}
URL url = Objects.requireNonNull(resource);
description = descriptionString;
location = resourceFileName;
try {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jabref/logic/util/BuildInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

public final class BuildInfo {

public static final String UNKNOWN_VERSION = "*unknown*";
public static final String UNKNOWN_VERSION = "unknown";

public static final String OS = System.getProperty("os.name", UNKNOWN_VERSION);
public static final String OS_VERSION = System.getProperty("os.version", UNKNOWN_VERSION).toLowerCase(Locale.ROOT);
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/jabref/logic/util/BuildInfoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class BuildInfoTest {
@Test
public void testDefaults() {
BuildInfo buildInfo = new BuildInfo("asdf");
assertEquals("*unknown*", buildInfo.version.getFullVersion());
assertEquals("unknown", buildInfo.version.getFullVersion());
}

@Test
Expand Down