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 support for property editing #65

Open
checkcast opened this issue Jul 16, 2024 · 2 comments
Open

Add support for property editing #65

checkcast opened this issue Jul 16, 2024 · 2 comments

Comments

@checkcast
Copy link

It would be nice to be able to set server.properties values in the runServer block, like online-mode, server port or name (which could be defaulted to something like '${project.name} test server').

@ryantheleach
Copy link

ryantheleach commented Oct 11, 2024

I've currently been trying and failing to create a gradle task that creates a partial server.properties before RunServer runs.

    register<WriteProperties>("writeProperties") {
        tasks.withType<RunServer> {
            dependsOn(this@register)
        }

        destinationFile = runServer.runDirectory.file("server.properties")
        encoding = "UTF-8"
        property("online-mode", false)
        property("gamemode", 1)
        property("motd", "debug server")
        property("enable-command-block", true)
    }

Would appreciate any advice.

@ryantheleach
Copy link

I nearly gave up, but managed to get it to work.

register is config avoidant, where as create will run the configuration.

    create<WriteProperties>("writeProperties") {
        runServer.configure {
            dependsOn(this@create)
            this@create.destinationFile.set(runDirectory.file("server.properties"))
        }

        encoding = "UTF-8"
        //property("online-mode", false)
        property("gamemode", 1)
        property("motd", "debug server")
        property("enable-command-block", true)
    }

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

No branches or pull requests

2 participants