开发者

How to script the "Convert to AspectJ" action when creating a new Eclipse project?

I have a command line script that creates a (mostly) ready-to-go Eclipse project for me. It uses Maven's eclipse plugin, and has some other scripted steps such as copying our code standard settings from our repo into开发者_开发技巧 .settings. This is very handy, since I need to spin up new projects often, from this one template. (For branch work, one-off dev experiments, etc.)

But the project uses AspectJ. I can't figure out how to automatically tell Eclipse that it needs to "Convert to AspectJ", so I have to do this manually within Eclipse every time I create a new project.

Is there a way to configure the Eclipse project from the command line to consider itself an AspectJ project? I'm using Eclipse 3.4.2 and The AspectJ plugin 2.0.0.


you need this config inside your maven poms (see maven eclipse plugin: adding additional project natures)

  <plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <configuration>
      <additionalProjectnatures>
        <projectnature>org.eclipse.ajdt.ui.ajnature</projectnature>
      </additionalProjectnatures>
      <additionalBuildcommands>
        <buildcommand>org.eclipse.ajdt.core.ajbuilder</buildcommand>
      </additionalBuildcommands>
    </configuration>
  </plugin>

This will activate AJDT builder and nature automatically, but I don't think there is a way to specify this via command line. But this solves part of the problem, at least.


You need to make changes to the .project file as well as your .classpath file.

Your .project file should look something like this:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>my.project.name</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
    <buildCommand>
        <name>org.eclipse.ajdt.core.ajbuilder</name>
        <arguments>
        </arguments>
    </buildCommand>
</buildSpec>
<natures>
    <nature>org.eclipse.ajdt.ui.ajnature</nature>
    <nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

And in your .classpath, you need to include the AspectJ runtime, which you can do by adding this line:

<classpathentry kind="con" path="org.eclipse.ajdt.core.ASPECTJRT_CONTAINER"/>

This is all assuming that you are creating a simple project and does not include any maven support. Based on your question, I am a little unsure exactly what you are looking for.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜