Skip to content

I can't set this up with Gradle #47

@Souvlaki42

Description

@Souvlaki42

I forked this legacy piece of software used in my university, to merge some PRs and add dark mode support through flatlaf: https://github.com/dpetersanderson/MARS and https://github.com/Souvlaki42/MARS

build.grade:

plugins {
    // Apply the application plugin to add support for building a CLI application in Java.
    id 'application'
}

version = '4.7'

application {
    // Define the main class for the application.
    mainClass = 'Mars'
}

java {
    withJavadocJar()
    withSourcesJar()

    sourceCompatibility = JavaVersion.VERSION_11
    targetCompatibility = JavaVersion.VERSION_11
}

javadoc {
}

jar {
    manifest {
        attributes['Implementation-Title'] = project.name
        attributes['Implementation-Version'] = project.version
        attributes['Main-Class'] = application.mainClass
    }
}

dependencies {
    implementation 'com.formdev:flatlaf:3.6.2'
    implementation 'com.github.Dansoftowner:jSystemThemeDetector:3.6'
}

settings.gradle:

rootProject.name = 'Mars'

dependencyResolutionManagement {
	repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
	repositories {
		mavenCentral()
		maven { url = 'https://jitpack.io' }
	}
}

Followed this: https://jitpack.io/#Dansoftowner/jSystemThemeDetector

But importing it like this:

import com.formdev.flatlaf.FlatDarkLaf;
import com.formdev.flatlaf.FlatLaf;
import com.formdev.flatlaf.FlatLightLaf;
import com.jthemedetector.OsThemeDetector;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;

public class Mars {

    public static void main(String[] args) {
        final OsThemeDetector detector = OsThemeDetector.getDetector();
        final boolean isDarkThemeUsed = detector.isDark();

        if (isDarkThemeUsed) {
            FlatDarkLaf.setup();
        } else {
            FlatLightLaf.setup();
        }

        detector.registerListener(isDark -> {
            SwingUtilities.invokeLater(() -> {
                try {
                    if (isDark) {
                        UIManager.setLookAndFeel(new FlatDarkLaf());
                    } else {
                        UIManager.setLookAndFeel(new FlatLightLaf());
                    }
                    FlatLaf.updateUI();
                } catch (Exception e) {
                    e.printStackTrace();
                }
            });
        });

        new mars.MarsLaunch(args);
    }
}

Still doesn't resolve in the editor or after running this:

./gradlew clean build --refresh-dependencies

Am I doing something wrong or is the process broken? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions