Static Weaving through Eclipse Plug-in [message #536189] |
Thu, 27 May 2010 06:57  |
Eclipse User |
|
|
|
Hi,
I am wondering whether it is planned to include static weaving as a feature in the Dali/EclipseLink Support plug-in in the future.
I think this would fundamentally ease static weaving, since current methods (e.g., ant task) are quite cumbersome to install - especially in a distributed development environment.
A similar feature exists for example in the Google Eclipse plug-in for App Engine, where the DataNucleus Enhancer is automatically run after each build.
Best regards,
marco
|
|
|
|
|
Re: Static Weaving through Eclipse Plug-in [message #538564 is a reply to message #538313] |
Mon, 07 June 2010 20:57   |
Eclipse User |
|
|
|
Hi Marco,
I use Maven and Eclipse (and the Maven Eclipse plugin) as well. I set
up a launch config in Eclipse to execute static weaving on demand, and
here it is as exported:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.jdt.launching.localJavaApplication">
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/***PROJECT***"/>
</listAttribute>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE"
value="org.eclipse.persistence.tools.weaving.jpa.StaticWeave "/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS"
value="-loglevel FINEST -persistenceinfo src/main/resources
target/classes target/classes"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR"
value="***PROJECT***"/>
</launchConfiguration>
You can replace the "***PROJECT***" placeholders with your Eclipse
project name and then import that launch config, if you'd like. Notice
the MAIN_TYPE and PROGRAM_ARGUMENTS. As long as the eclipselink JAR is
in your Build Path, this should work for you.
Also, here's the relevant part of my Maven config (including an
alternate, commented-out version):
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>JPA Enhancement</id>
<phase>process-classes</phase>
<configuration>
<tasks>
<taskdef
name="weave"
classname=" org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask "
classpathref="maven.test.classpath"/>
<weave
loglevel="FINEST"
source="${basedir}/target/classes"
target="${basedir}/target/classes"
persistenceinfo="${basedir}/src/main/resources">
<classpath refid="maven.test.classpath"/>
</weave>
<!--
<java
classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeave "
classpathref="maven.test.classpath"
fork="true">
<arg
line="-loglevel FINEST -persistenceinfo
src/main/resources target/classes target/classes"/>
</java>
-->
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
and here's where I originally got it from:
http://www.tzavellas.com/techblog/2008/10/17/statically-weav ing-jpa-entities-for-eclipselink-using-maven/
Best regards,
Ari
marco wrote:
> Hi Shaun,
>
> first of all thanks for your answer. Indeed, dynamic weaving is the
> preferable option - however, not applicable for JUnit Testing as well as
> deployments to Tomcat (which is our current deployment target).
> I played around with integrating the ant task in our Eclipse build, but
> with limited success. This may be due to our "special" dev config. We
> use Maven (and the Maven Eclipsep plug-in) for dependency management as
> well as for packaging the application. Regular builds during development
> are done in Eclipse. However, due to using Maven our dependencies are
> kept outside from the application path during development (in the maven
> user repo). Using the ant task I experienced that these dependencies
> cannot be accessed without setting an absolute classpath for every
> developer (or duplicating the jars within the application path).
> Therefore, I stopped investigating a solution relying on the Ant task.
> If there is an option to do so, I would appreciate any hints.
> In the meantime I will file an RFE for Dali as you proposed.
>
> Thanks, marco
|
|
|
|
|
|
|
|
|
Re: Static Weaving through Eclipse Plug-in [message #542146 is a reply to message #541292] |
Thu, 24 June 2010 00:52  |
Eclipse User |
|
|
|
I've been doing static weaving from within Eclipse for my JPA projects by simply defining an ant script to perform the weaving and adding it to the build process in the project properties. I really don't think anyone needs to write a plugin when this can be incorporated into the build process so easily. I never use dynamic weaving.
Here is the script. Simply edit it accordingly.
<?xml version="1.0"?>
<project name="jpa-weaving" default="weaving" basedir="./../..">
<property environment="env"/>
<property name="glassfish.home" value="${env.GLASSFISH_HOME}"/>
<path id="weavingclasspath">
<pathelement location="${glassfish.home}/lib/javaee.jar"/>
<pathelement location="${glassfish.home}/modules/org.eclipse.persistence.core.jar"/>
<pathelement location="${glassfish.home}/modules/org.eclipse.persistence.jpa.jar"/>
</path>
<target name="define.task" description="New task definition for EclipseLink static weaving" >
<taskdef name="weave" classname="org.eclipse.persistence.tools.weaving.jpa.StaticWeaveAntTask">
<classpath refid="weavingclasspath"/>
</taskdef>
</target>
<target name="weaving" description="perform weaving" depends="define.task">
<weave source="${basedir}/target/classes" target="${basedir}/target/classes">
<classpath refid="weavingclasspath"/>
</weave>
</target>
</project>
|
|
|
Powered by
FUDForum. Page generated in 0.04353 seconds