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

Problem when creating default configuration #12

Open
s1ck opened this issue Sep 8, 2023 · 2 comments
Open

Problem when creating default configuration #12

s1ck opened this issue Sep 8, 2023 · 2 comments

Comments

@s1ck
Copy link

s1ck commented Sep 8, 2023

Hey, I am trying to configure the plugin in an existing Gradle project. Your example project runs just fine. However, when I add the plugin to the existing project, I get:

An exception occurred applying plugin request [id: 'fr.stardustenterprises.rust.wrapper']
> Failed to apply plugin 'fr.stardustenterprises.rust.wrapper'.
   > Cannot add a configuration with name 'default' as a configuration with that name already exists.

Which is caused by:

If a default configuration already exists (which is the case here), it throws.

I am not sure if creating a configuration is strictly necessary, but if so, we could change the call to .maybeCreate which has create-if-not-exists semantics. wdyt?

@s1ck
Copy link
Author

s1ck commented Sep 8, 2023

I could verify locally that this solves the problem, but it continues with:

> Failed to apply plugin 'fr.stardustenterprises.rust.wrapper'.
   > Cannot add task 'build' as a task with that name already exists.

I can successfully integrate it my project if I rename the tasks, i.e.

@Task(group = "rust", name = "buildRust")
@Task(group = "rust", name = "testRust")
@Task(group = "rust", name = "runRust")
@Task(group = "rust", name = "cleanRust")

What do you think? Should I open a PR for that change?

[edit] Seems to be somewhat the default, e.g. for the python gradle plugin:

Python tasks
------------
checkPython - Validate python environment
cleanPython - Removes existing python environment (virtualenv)
pipInstall - Install pip modules
pipList - Show all installed modules
pipUpdates - Check if new versions available for declared pip modules

@xtrm-en
Copy link
Member

xtrm-en commented Sep 8, 2023

Hey, thanks for the feedback!
gradle-rust works in a very odd manner right now: it bundles two Gradle plugins:

  • the wrapper plugin (fr.stardustenterprises.rust.wrapper)
  • the importer plugin (fr.stardustenterprises.rust.importer)

The wrapper plugin was originally intended to be used in a rust-only module, to be then imported via the importer plugin in a second Gradle subproject.

This behavior isn't ideal but was the one I deemed sufficient enough with my at-the-time limited knowledge of proper Gradle ways, to work in all cases, albeit with a bit of refactoring.

As per your proposals:

  • maybeCreate for the configuration is definitely a good idea, you can PR that in right away if you'd like and I'll publish it in a day or so
  • pre/suffixing tasks names that clash with default Gradle ones is a bit trickier, since those need to work for every other plugin that hook into them, and in the right order for dependencies (maybe Gradle handles this automagically?). If you want and open a PR for that too that'll be lovely of course.

I'll try and look into how I can improve the developer experience with gradle-rust based on that second point (i.e. not splitting the project in two plugins), but do note that it'll probably take a bit of time as I'm taking a break from programming to handle changes and life in general 👍

You can also try and separate your module layout to work in the current gradle-rust fashion if that's possible for your workflow; there isn't much in terms of proper documentation, only this example project which should serve as a bare-bones template.

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