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

jMolecules and ByteBuddy Support with IntelliJ IDEA #292

Open
bekaChichua opened this issue Nov 30, 2024 · 3 comments
Open

jMolecules and ByteBuddy Support with IntelliJ IDEA #292

bekaChichua opened this issue Nov 30, 2024 · 3 comments

Comments

@bekaChichua
Copy link

bekaChichua commented Nov 30, 2024

I am experiencing several issues when working with the jMolecules framework in IntelliJ IDEA. These issues affect both application runtime and development experience in the IDE:

1. Run Configuration Issue:

  • The application fails to start unless I manually configure a “Before Launch” task in the IntelliJ run configuration to execute mvn compile. I’m unsure if I’m misconfiguring something or if this feature is not yet fully implemented. I was unable to find any relevant information about this online.

2. ByteBuddy Code Generation:

  • Even after configuring the “Before Launch” task, ByteBuddy fails to generate the required code for transforming associations into associated aggregate IDs. This leads to runtime failures when saving or retrieving aggregates using Spring Data JDBC. Is ByteBuddy supposed to generate this converter, or should I implement a custom converter?
  • I ask because I noticed the existence of AssociationResolver, and it seems its purpose is to create such a converter. However, in my project, it fails to do so. Here’s an example:
@Getter
@Table("test_order")
public class Order implements AggregateRoot<Order, OrderId> {

    private final OrderId id;
    private final Association<Customer, Customer.CustomerId> customer;

    // If I use this constructor, JDBC will not be able to convert UUID into CustomerId without a custom converter
    public Order(OrderId id, Association<Customer, Customer.CustomerId> customer) {
        this.id = id;
        this.customer = customer;
    }

    public Order(OrderId id, UUID customer) {
        this.id = id;
        this.customer = Association.forId(new Customer.CustomerId(customer));
    }

    public static Order of(Customer customer) {
        return new Order(new OrderId(UUID.randomUUID()), customer.getId().id());
    }

    public record OrderId(UUID id) implements Identifier {
    }
}

3. IDE Warnings:

  • IntelliJ still incorrectly flags errors or warnings in the code. For example, during dependency injection, it shows: "Could not autowire. No beans of 'OrderService' type found. " This happens even when I configure the “Before Launch” task in the run configuration and ByteBuddy generates the necessary beans and application actually works.

Here is my repo: https://github.com/bekaChichua/jmolecules-example

If I’m missing something, please provide resources or guidance on how to resolve these IntelliJ-specific issues. Alternatively, if there are any workarounds you can suggest, I would greatly appreciate it. I’ve spent a lot of time searching for solutions, but there doesn’t seem to be much documentation available, likely because this project is relatively new.

Thank you for your help!

@odrotbohm
Copy link
Member

odrotbohm commented Dec 11, 2024

This is a known issue with IDEA. I can only recommend raising your voice in the linked ticket. Otherwise, the IDEA team will continue to assume that this is not a problem worth solving.

Here's the note one of my sample projects contains:

… Open the Maven tool window and find the list of plugins included in the project. Expand byte-buddy, right click on transform-extended, and select Execute After Build and Execute After Rebuild.

I'll make sure, we're going to add a note about this to the documentation.

@odrotbohm odrotbohm transferred this issue from xmolecules/jmolecules Dec 11, 2024
@dschulten
Copy link

dschulten commented Dec 21, 2024

The IDEA team has thrown back the ball into jMolecule's field. They suggest to implement a byte buddy builder plugin for IDEA JPS ;-)

@odrotbohm
Copy link
Member

odrotbohm commented Dec 21, 2024

It doesn't, really. As it suggests the ByteBuddy plugin to do something JPS-specific, not jMolecules. I've replied again because it's neither about ByteBuddy nor JPS, actually. But yeah, it's tiring. 😔 On the other hand. Unless anyone else is willing to chime in with IDEA, I'll end up looking like “Ollie's asking for his personal fix.” at some point. That feels weird as I am not even using IDEA in my day-to-day work. So at some point I'll probably just stop caring.

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

3 participants