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

Add Dagger #518

Closed
wants to merge 10 commits into from
Closed

Add Dagger #518

wants to merge 10 commits into from

Conversation

koppor
Copy link
Member

@koppor koppor commented Sep 1, 2021

Google's Dagger seems to be a nice dependency injection framework [slides].

Since @Inject is also used by Afterburner, I had to remove private at some places. The dependency injection is not complete; there needs to be proper thought about the "modules". I started with Fetchers to bundle fetchers and adding a quick hack.

Current state: Does not compile:

First error:

Error occurred during initialization of boot layer
java.lang.module.FindException: Error reading module: C:\Users\koppor\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-gradle-plugin\1.5.30\7c6c270759e7959fc772c03af640b5129f5f8b2b\kotlin-gradle-plugin-1.5.30.jar
Caused by: java.lang.module.InvalidModuleDescriptorException: Package com.google.gson.stream not found in module

According to https://stackoverflow.com/q/67647474/873282, one has to use id 'org.jetbrains.kotlin.jvm' version '1.5.30'. Then, one gets following error:

Error occurred during initialization of boot layer
java.lang.module.FindException: Unable to derive module descriptor for C:\Users\koppor\.gradle\caches\modules-2\files-2.1\org.jetbrains.kotlin\kotlin-native-utils\1.5.30\4440710d4ed3d1669e6e3f6a94b3e0f50af053ff\kotlin-native-utils-1.5.30.jar
Caused by: java.lang.IllegalArgumentException: kotlin.native.utils: Invalid module name: 'native' is not a Java identifier

This probably can be solved by using a different JVM. See https://github.com/JetBrains/kotlin#build-environment-requirements for details.

  • Change in CHANGELOG.md described in a way that is understandable for the average user (if applicable)
  • Tests created for changes (if applicable)
  • Manually tested changed features in running JabRef (always required)
  • Screenshots added in PR description (for UI changes)
  • Checked documentation: Is the information available and up to date? If not, I created an issue at https://github.com/JabRef/user-documentation/issues or, even better, I submitted a pull request to the documentation repository.

@koppor
Copy link
Member Author

koppor commented Sep 1, 2021

Example generated code:

// Generated by Dagger (https://dagger.dev).
package org.jabref.cli;

import dagger.Lazy;
import dagger.MembersInjector;
import dagger.internal.DaggerGenerated;
import dagger.internal.DoubleCheck;
import dagger.internal.InjectedFieldSignature;
import javax.inject.Provider;
import org.jabref.logic.util.BuildInfo;

@DaggerGenerated
@SuppressWarnings({
    "unchecked",
    "rawtypes"
})
public final class JabRefCLI_MembersInjector implements MembersInjector<JabRefCLI> {
  private final Provider<BuildInfo> buildInfoProvider;

  public JabRefCLI_MembersInjector(Provider<BuildInfo> buildInfoProvider) {
    this.buildInfoProvider = buildInfoProvider;
  }

  public static MembersInjector<JabRefCLI> create(Provider<BuildInfo> buildInfoProvider) {
    return new JabRefCLI_MembersInjector(buildInfoProvider);
  }

  @Override
  public void injectMembers(JabRefCLI instance) {
    injectBuildInfo(instance, DoubleCheck.lazy(buildInfoProvider));
  }

  @InjectedFieldSignature("org.jabref.cli.JabRefCLI.buildInfo")
  public static void injectBuildInfo(JabRefCLI instance, Lazy<BuildInfo> buildInfo) {
    instance.buildInfo = buildInfo;
  }
}

# Conflicts:
#	src/main/java/org/jabref/gui/entryeditor/RelatedArticlesTab.java
#	src/main/java/org/jabref/preferences/JabRefPreferences.java
@koppor koppor mentioned this pull request May 27, 2024
6 tasks
@koppor
Copy link
Member Author

koppor commented May 27, 2024

Superseeded by #687

@koppor koppor closed this May 27, 2024
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.

1 participant