Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Annotation processing, Project specific or project only setting?(Why not a workspace setting for annotation processing?)
Annotation processing, Project specific or project only setting? [message #897116] Sat, 21 July 2012 21:13 Go to next message
Santiago Ruiz is currently offline Santiago Ruiz
Messages: 13
Registered: July 2009
Junior Member
Hi all

first, thanks for stay there. We need you more than you need us.

I've contributed the platform with an annotation processor (in fact there's no annotation, it's only a processor).

I think all projects should be aware of my processor. I'd like my processor were used with no aditional effort by my clients but it seems it's impossible (perhaps it's possible to extend the "new java project" wizard).

There must be a reason why:

1.- Annotation processing is not enabled by default
2.- There's no such an option at workspace scope

Please, explain me that reason
Re: Annotation processing, Project specific or project only setting? [message #897117 is a reply to message #897116] Sat, 21 July 2012 21:54 Go to previous messageGo to next message
Santiago Ruiz is currently offline Santiago Ruiz
Messages: 13
Registered: July 2009
Junior Member
Mr Santiago Doe. You must follow the forum rules Smile

http://www.eclipse.org/forums/index.php/t/80143/

i've followed the rules, i promise, but i've found the topic too late. Sorry

In any case ...

why do you tag a setting as 'project specific' when that setting has no global correlative?
Re: Annotation processing, Project specific or project only setting? [message #897132 is a reply to message #897116] Sun, 22 July 2012 04:07 Go to previous message
Santiago Ruiz is currently offline Santiago Ruiz
Messages: 13
Registered: July 2009
Junior Member
Mister Santiago. I understand your problem. I was working on a solution for you (and perhaps for others Wink)

I hope you'll be a better poster in a near future

public class Startup implements IStartup {
    @Override
    public void earlyStartup() {
        try {
            for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
                if (project.isNatureEnabled(JavaCore.NATURE_ID)) {
                    IJavaProject javaProject = JavaCore.create(project);
                    if (!AptConfig.isEnabled(javaProject)) {
                        AptConfig.setEnabled(javaProject, true);
                    }
                }
            }

            IResourceChangeListener listener = new IResourceChangeListener() {
                @Override
                public void resourceChanged(IResourceChangeEvent event) {
                    IResourceDelta rootChange = event.getDelta();
                    for (IResourceDelta projectChange:rootChange.getAffectedChildren()) {
                        if (projectChange.getKind() == IResourceDelta.ADDED) {
                            IProject project = (IProject)projectChange.getResource();
                            try {
                                if (project.isNatureEnabled(JavaCore.NATURE_ID)) {
                                    IJavaProject javaProject = JavaCore.create(project);
                                    if (!AptConfig.isEnabled(javaProject)) {
                                        AptConfig.setEnabled(javaProject, true);
                                    }
                                }
                            } catch (CoreException e) {
                                throw new RuntimeException(e);
                            }                            
                        }
                    }
                }
            };
            
            ResourcesPlugin.getWorkspace().addResourceChangeListener(listener, IResourceChangeEvent.PRE_BUILD);
        
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    }
}
Previous Topic:How to keep Java editor from auto scrolling?
Next Topic:OSGi Classloader Problem
Goto Forum:
  


Current Time: Thu Aug 21 22:17:22 EDT 2014

Powered by FUDForum. Page generated in 0.01666 seconds