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

Prepare multi module build #3913

Merged
merged 20 commits into from
Apr 16, 2018
Merged

Prepare multi module build #3913

merged 20 commits into from
Apr 16, 2018

Conversation

koppor
Copy link
Member

@koppor koppor commented Mar 31, 2018

This is a follow-up to #3704. This PR separates logic and UI at more places. It cannot easily be based on maintable-beta (#3621). I propose following procedure:

  1. Get this ready to be merged into master
  2. Merge master into maintable-beta ([WIP] Main table JavaFX migration #3621)

For the first step, just the following is open:

  • The OO preferences should be fixed (reading/writing not fully supported yet). All other features should work.

- FreeCite does not generate a non-used BibtexKeyGenerator anymore
- Introduce ExporterFactoryFactory
- Introduce SavePreferenceFactory
# Conflicts:
#	src/main/java/org/jabref/preferences/JabRefPreferences.java
# Conflicts:
#	src/main/java/org/jabref/JabRefMain.java
#	src/main/java/org/jabref/gui/BasePanel.java
# Conflicts:
#	src/main/java/org/jabref/gui/BasePanel.java
#	src/main/java/org/jabref/preferences/SavePreferencesFactory.java
@koppor koppor mentioned this pull request Mar 31, 2018
8 tasks
Copy link
Member

@tobiasdiez tobiasdiez left a comment

Choose a reason for hiding this comment

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

I've only very minor remarks and the code looks good. The OO stuff has to work obviously before merge.

@@ -172,7 +171,7 @@ private Reader getReader(String filename) throws IOException {
String name = dir + filename;
Reader reader;
// Try loading as a resource first. This works for files inside the JAR:
URL reso = JabRefMain.class.getResource(name);
URL reso = TemplateExporter.class.getResource(name);
Copy link
Member

Choose a reason for hiding this comment

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

Now name needs to be relative to org/jabref/logic/exporter/ and not org/jabref/ right?

Copy link
Member Author

Choose a reason for hiding this comment

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

I checked the code and tried out the UI:

grafik

The UI works and the code IMHO never goes that path. With that change, the code is prepared for testing the "TemplateExporter".

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, but I don't really get what you want to say. You tested it and it worked although the changed code was never invoked?

String dir;
if (customExport) {
dir = "";
} else {
dir = LAYOUT_PREFIX + (directory == null ? "" : directory + '/');
}
// Attempt to get a Reader for the file path given, either by
// loading it as a resource (from within JAR), or as a normal file. If
// unsuccessful (e.g. file not found), an IOException is thrown.
String name = dir + filename;

Gives a name of the form /resource/layout/<exporter name>.layout. With the above change, I suspect that all layout files in src/main/resources/resource/layout are no longer found and thus the corresponding exporter stop to work.

Copy link
Member Author

Choose a reason for hiding this comment

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

TL;DR: The given name is absolute, so it does not matter which class is used.

Longer reasoning (with debugging JabRef):

JabRefs main class is in org.jabref, so the path changes from

file:/C:/git-repositories/jabref/jabref/out/production/resources/resource/layout/html.begin.layout

to

file:/C:/git-repositories/jabref/jabref/out/production/resources/resource/layout/html.begin.layout

So, no change when debugging JabRef.

I think, it is because the parameter directory is given and thus the path is an absolute one. (Source: https://docs.oracle.com/javase/7/docs/api/java/lang/Class.html#getResource(java.lang.String))

I would like to change the path to enable the test files residing in the test resources folder of "TemplateExporter".

Copy link
Member

Choose a reason for hiding this comment

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

Ok, if it works then the change is of course fine with me. I was only concerned that the exporter may break.


public class ExporterFactoryFactory {

public static ExporterFactory create(JabRefPreferences preferences, JournalAbbreviationLoader abbreviationLoader) {
Copy link
Member

Choose a reason for hiding this comment

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

What about moving this method to JabRefPreferences as an instance method createExportFactory(abbrLoader)?

@@ -1421,6 +1425,41 @@ public ImportFormatPreferences getImportFormatPreferences() {
isKeywordSyncEnabled());
}

public static SavePreferences loadForExportFromPreferences(JabRefPreferences preferences) {
Copy link
Member

Choose a reason for hiding this comment

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

Convert these two methods to instance methods and rename them to something like loadSavePreferencesForExport

Copy link
Member Author

Choose a reason for hiding this comment

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

Seems, I was too tired at JabCon to see the obvious.

@@ -18,7 +17,7 @@

@Test
public void containsReturnsTrueForEntryInAux() throws Exception {
Path auxFile = Paths.get(AuxParserTest.class.getResource("paper.aux").toURI());
Path auxFile = Paths.get(TexGroupTest.class.getResource("paper.aux").toURI());
Copy link
Member

Choose a reason for hiding this comment

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

Whats the reason for this change? The only "advantage" is that we now have a copy of the paper.aux file...

Copy link
Member Author

Choose a reason for hiding this comment

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

I had the fear that maintainers of the AuxParserTest do not know that the TexGroupTest also relies on the aux file. What if another test is created? I would separate tests of different classes as much as possible even if files (.bib, .aux, ...) are duplicated.

@koppor koppor self-assigned this Apr 12, 2018
…e-build

# Conflicts:
#	src/main/java/org/jabref/cli/ArgumentProcessor.java
#	src/main/java/org/jabref/logic/exporter/ExporterFactory.java
@koppor
Copy link
Member Author

koppor commented Apr 13, 2018

OO fixed in 5c8e3e9. Tested in the UI.

So, ready for review 😇

@koppor koppor added the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Apr 13, 2018
@koppor koppor removed the status: ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Apr 16, 2018
@koppor koppor changed the title [WIP] Prepare multi module build Prepare multi module build Apr 16, 2018
@koppor
Copy link
Member Author

koppor commented Apr 16, 2018

Since @Siedlerchr gave his "OK" and @tobiasdiez reviewed the intermediate steps, I'll fix the tests and merge to keep things moving.

@koppor koppor merged commit adc2e41 into master Apr 16, 2018
@koppor koppor deleted the prepare-multi-module-build branch April 16, 2018 07:29
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.

3 participants