maven-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Timo Westkämper <timo.westkam...@mysema.com>
Subject Re: How to compile QueryDSL sources from post-processed .class files in Maven?
Date Wed, 24 Apr 2013 06:44:11 GMT
Hi.

It should be possible to use the Java Compiler API in the Querydsl maven
plugin to compile.

I will comment more later on the related issue.

Br,
Timo

On Wed, Apr 24, 2013 at 1:43 AM, Querydsl on behalf of Matthew Adams <
querydsl@googlegroups.com> wrote:

> Hi all,
>
> I'm using aspectj to introduce fields into my persistent entities, then
> using QueryDSL's querydsl-maven-plugin's jpa-export goal to produce the
> QueryDSL Q-classes during Maven's process-classes phase, since that's the
> earliest point at which I can ensure that the persistent entities have been
> fully woven.
>
> After querydsl-maven-plugin's jpa-export goal runs, I have new sources in
> target/generated-sources/querydsl and need to compile them to
> target/classes.  I tried configuring the maven-compiler-plugin to achieve
> the compile goal during the process-classes phase, but it keeps thinking
> that everything is up to date and that there's nothing to compile, because
> the maven-compiler-plugin's compileSourceRoots is read-only and is
> src/main/java.  Even if I use build-helper-maven-plugin to add another
> source directory (target/generated-sources/querydsl), the javac compilation
> fails because src/main/java contains classes that are receiving aspectj
> introductions and I can't remove src/main/java from the compileSourceRoots
> (I can only add via build-helper-maven-plugin).
>
> Here's my relevant config (rolling dice on formatting below):
>
> <plugin>
>  <groupId>com.mysema.querydsl</groupId>
> <artifactId>querydsl-maven-plugin</artifactId>
>  <executions>
> <execution>
>  <phase>process-classes</phase>
> <goals>
>  <goal>jpa-export</goal>
> </goals>
>  <configuration>
>
> <targetFolder>${project.build.directory}/generated-sources/querydsl</targetFolder>
>  <handleMethods>false</handleMethods>
> <packages>
>  <package>app.domain.model</package>
> </packages>
>  </configuration>
> </execution>
>  </executions>
> </plugin>
>  <plugin>
> <groupId>org.codehaus.mojo</groupId>
>  <artifactId>build-helper-maven-plugin</artifactId>
> <executions>
>  <execution>
> <id>add-source</id>
>  <phase>process-classes</phase>
> <goals>
>  <goal>add-source</goal>
> </goals>
>  <configuration>
> <sources>
>  <source>${project.build.directory}/generated-sources/querydsl</source>
> </sources>
>  </configuration>
> </execution>
>  </executions>
> </plugin>
>  <plugin>
> <artifactId>maven-compiler-plugin</artifactId>
>  <executions>
> <execution>
>  <id>compile-querydsl-classes</id>
> <goals>
>  <goal>compile</goal>
> </goals>
>  <phase>process-classes</phase>
> <configuration>
>  <source>1.6</source>
> <target>1.6</target>
>  <debug>true</debug>
> <encoding>UTF-8</encoding>
>  <failOnError>true</failOnError>
> <verbose>true</verbose>
>  <skipMain>false</skipMain>
> <skip>true</skip>
>  </configuration>
> </execution>
>  </executions>
> </plugin>
>
> I also tried switching to maven-antrun-plugin in an effort to use the
> <javac> task, but the generated sources are causing the java compiler
> (1.6.0_33 & 1.6.0_45 on Mac OS X 10.8) to throw NPE; same for using ant's
> <exec executable="javac"> task.
>
> Config:
>
> <plugin>
> <artifactId>maven-antrun-plugin</artifactId>
>  <version>1.7</version>
> <executions>
>  <execution>
> <id>compile-querydsl-classes</id>
>  <phase>process-classes</phase>
> <goals>
>  <goal>run</goal>
> </goals>
>  <configuration>
> <target>
>  <property
> name="srcdir"
>  value="${basedir}/target/generated-sources/querydsl" />
> <property
>  name="destdir"
> value="${basedir}/target/classes" />
>  <property
> name="cp"
>  refid="maven.compile.classpath" />
> <fileset
>  id="srcfileset"
> dir="${srcdir}">
>  <include name="**/*" />
> </fileset>
>  <pathconvert
> property="srcfiles"
>  refid="srcfileset"
> pathsep=" " />
>  <echo message="srcdir=${srcdir}" />
> <echo message="destdir=${destdir}" />
>  <echo message="srcfiles=${srcfiles}" />
>
>  <property
> name="argline"
>  value="-g -verbose -d ${destdir} -cp ${cp} ${srcfiles}" />
> <echo message="argline=${argline}" />
>  <exec executable="javac">
> <arg line="${argline}" />
>  </exec>
> </target>
>  </configuration>
> </execution>
>  </executions>
> </plugin>
>
>
> Result:
>
> Execute:Java13CommandLauncher: Executing 'javac' with arguments:
> '-g'
> '-verbose'
> '-d'
>
> '/Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/classes'
> '-cp'
> ...[snip]...
>
> '/Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/generated-sources/querydsl/app/domain/model/QAddress.java'
>
> '/Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/generated-sources/querydsl/app/domain/model/QGeneration.java'
>
> '/Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/generated-sources/querydsl/app/domain/model/QLocalizedString.java'
>
> '/Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/generated-sources/querydsl/app/domain/model/QPerson.java'
>
> '/Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/generated-sources/querydsl/app/domain/model/QUser.java'
>
> The ' characters around the executable and arguments are
> not part of the command.
>      [exec] [parsing started
> /Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/generated-sources/querydsl/app/domain/model/QAddress.java]
>      [exec] [parsing completed 8ms]
>      [exec] [parsing started
> /Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/generated-sources/querydsl/app/domain/model/QGeneration.java]
>      [exec] [parsing completed 1ms]
>      [exec] [parsing started
> /Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/generated-sources/querydsl/app/domain/model/QLocalizedString.java]
>      [exec] [parsing completed 1ms]
>      [exec] [parsing started
> /Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/generated-sources/querydsl/app/domain/model/QPerson.java]
>      [exec] [parsing completed 3ms]
>      [exec] [parsing started
> /Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/generated-sources/querydsl/app/domain/model/QUser.java]
>      [exec] [parsing completed 3ms]
>      [exec] [search path for source files: ...[snip]...
>
>      [exec] [loading
> com/mysema/query/types/PathMetadataFactory.class(com/mysema/query/types:PathMetadataFactory.class)]
>      [exec] [loading java/lang/Object.class(java/lang:Object.class)]
>      [exec] [loading
> com/mysema/query/types/PathMetadata.class(com/mysema/query/types:PathMetadata.class)]
>      [exec] [loading
> javax/annotation/Generated.class(javax/annotation:Generated.class)]
>      [exec] [loading
> com/mysema/query/types/Path.class(com/mysema/query/types:Path.class)]
>      [exec] [loading
> com/mysema/query/types/path/EntityPathBase.class(com/mysema/query/types/path:EntityPathBase.class)]
>      [exec] [loading
> /Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/classes/app/domain/model/Address.class]
>      [exec] [loading
> com/mysema/query/types/EntityPath.class(com/mysema/query/types:EntityPath.class)]
>      [exec] [loading
> com/mysema/query/types/Expression.class(com/mysema/query/types:Expression.class)]
>      [exec] [loading
> java/io/Serializable.class(java/io:Serializable.class)]
>      [exec] [loading
> com/mysema/query/types/path/BeanPath.class(com/mysema/query/types/path:BeanPath.class)]
>      [exec] [loading
> com/mysema/query/types/expr/SimpleExpression.class(com/mysema/query/types/expr:SimpleExpression.class)]
>      [exec] [loading
> com/mysema/query/types/expr/DslExpression.class(com/mysema/query/types/expr:DslExpression.class)]
>      [exec] [loading
> com/mysema/query/types/path/StringPath.class(com/mysema/query/types/path:StringPath.class)]
>      [exec] [loading
> com/mysema/query/types/path/SimplePath.class(com/mysema/query/types/path:SimplePath.class)]
>      [exec] [loading
> javax/persistence/EntityManager.class(javax/persistence:EntityManager.class)]
>      [exec] [loading
> com/mysema/query/types/path/NumberPath.class(com/mysema/query/types/path:NumberPath.class)]
>      [exec] [loading java/lang/Long.class(java/lang:Long.class)]
>      [exec] [loading java/lang/String.class(java/lang:String.class)]
>      [exec] [loading
> /Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/classes/app/domain/model/Generation.class]
>      [exec] [loading
> com/mysema/query/types/path/EnumPath.class(com/mysema/query/types/path:EnumPath.class)]
>      [exec] [loading
> /Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/classes/app/domain/model/GenerationFormat.class]
>      [exec] [loading java/lang/Integer.class(java/lang:Integer.class)]
>      [exec] [loading
> /Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/classes/app/domain/model/LocalizedString.class]
>      [exec] [loading
> com/mysema/query/types/path/MapPath.class(com/mysema/query/types/path:MapPath.class)]
>      [exec] [loading
> com/mysema/query/types/path/PathInits.class(com/mysema/query/types/path:PathInits.class)]
>      [exec] [loading
> /Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/classes/app/domain/model/Person.class]
>      [exec] [loading
> com/mysema/query/types/path/DateTimePath.class(com/mysema/query/types/path:DateTimePath.class)]
>      [exec] [loading java/util/Date.class(java/util:Date.class)]
>      [exec] [loading
> com/mysema/query/types/path/ListPath.class(com/mysema/query/types/path:ListPath.class)]
>      [exec] [loading java/lang/Class.class(java/lang:Class.class)]
>      [exec] [loading
> /Users/matthew/Documents/foundation/foundation/test-client/jpa/domain/target/classes/app/domain/model/User.class]
>      [exec] [loading
> java/lang/annotation/Retention.class(java/lang/annotation:Retention.class)]
>      [exec] [loading
> java/lang/annotation/RetentionPolicy.class(java/lang/annotation:RetentionPolicy.class)]
>      [exec] [loading
> java/lang/annotation/Target.class(java/lang/annotation:Target.class)]
>      [exec] [loading
> java/lang/annotation/ElementType.class(java/lang/annotation:ElementType.class)]
>      [exec] [loading
> com/scispike/foundation/domain/trait/persistence/Persistable.class(com/scispike/foundation/domain/trait/persistence:Persistable.class)]
>      [exec] [loading
> com/scispike/foundation/domain/trait/persistence/IdType.class(com/scispike/foundation/domain/trait/persistence:IdType.class)]
>      [exec] [loading
> com/scispike/foundation/domain/trait/persistence/StoreType.class(com/scispike/foundation/domain/trait/persistence:StoreType.class)]
>      [exec] [loading
> javax/persistence/Column.class(javax/persistence:Column.class)]
>      [exec] [loading
> java/lang/annotation/Annotation.class(java/lang/annotation:Annotation.class)]
>      [exec] [loading
> java/lang/SuppressWarnings.class(java/lang:SuppressWarnings.class)]
>      [exec] [loading
> javax/persistence/Enumerated.class(javax/persistence:Enumerated.class)]
>      [exec] [loading
> javax/persistence/EnumType.class(javax/persistence:EnumType.class)]
>      [exec] [loading
> javax/persistence/CollectionTable.class(javax/persistence:CollectionTable.class)]
>      [exec] [loading
> javax/persistence/OneToOne.class(javax/persistence:OneToOne.class)]
>      [exec] [loading
> javax/persistence/CascadeType.class(javax/persistence:CascadeType.class)]
>      [exec] [loading
> javax/persistence/OneToMany.class(javax/persistence:OneToMany.class)]
>      [exec] [loading
> javax/persistence/JoinTable.class(javax/persistence:JoinTable.class)]
>      [exec] [loading
> javax/persistence/JoinColumn.class(javax/persistence:JoinColumn.class)]
>      [exec] [loading
> javax/persistence/MapKeyColumn.class(javax/persistence:MapKeyColumn.class)]
>      [exec] [loading
> javax/persistence/Table.class(javax/persistence:Table.class)]
>      [exec] [loading
> javax/persistence/FetchType.class(javax/persistence:FetchType.class)]
>      [exec] An exception has occurred in the compiler (1.6.0_45). Please
> file a bug at the Java Developer Connection (
> http://java.sun.com/webapps/bugreport)  after checking the Bug Parade for
> duplicates. Include your program and the following diagnostic in your
> report.  Thank you.
>      [exec] java.lang.NullPointerException
>      [exec] at
> com.sun.tools.javac.code.Symbol$MethodSymbol.params(Symbol.java:1196)
>      [exec] at
> com.sun.tools.javac.jvm.ClassReader.attachParameterAnnotations(ClassReader.java:1111)
>      [exec] at
> com.sun.tools.javac.jvm.ClassReader.readMemberAttr(ClassReader.java:871)
>      [exec] at
> com.sun.tools.javac.jvm.ClassReader.readMemberAttrs(ClassReader.java:1027)
>      [exec] at
> com.sun.tools.javac.jvm.ClassReader.readMethod(ClassReader.java:1490)
>      [exec] at
> com.sun.tools.javac.jvm.ClassReader.readClass(ClassReader.java:1586)
>      [exec] at
> com.sun.tools.javac.jvm.ClassReader.readClassFile(ClassReader.java:1658)
>      [exec] at
> com.sun.tools.javac.jvm.ClassReader.fillIn(ClassReader.java:1845)
>      [exec] at
> com.sun.tools.javac.jvm.ClassReader.complete(ClassReader.java:1777)
>      [exec] at com.sun.tools.javac.code.Symbol.complete(Symbol.java:384)
>      [exec] at
> com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:766)
>      [exec] at
> com.sun.tools.javac.jvm.ClassReader.loadClass(ClassReader.java:1951)
>      [exec] at
> com.sun.tools.javac.comp.Resolve.loadClass(Resolve.java:867)
>      [exec] at
> com.sun.tools.javac.comp.Resolve.findGlobalType(Resolve.java:926)
>      [exec] at com.sun.tools.javac.comp.Resolve.findType(Resolve.java:982)
>      [exec] at
> com.sun.tools.javac.comp.Resolve.findIdent(Resolve.java:1011)
>      [exec] at
> com.sun.tools.javac.comp.Resolve.resolveIdent(Resolve.java:1187)
>      [exec] at com.sun.tools.javac.comp.Attr.visitIdent(Attr.java:1714)
>      [exec] at
> com.sun.tools.javac.tree.JCTree$JCIdent.accept(JCTree.java:1547)
>      [exec] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
>      [exec] at com.sun.tools.javac.comp.Attr.attribType(Attr.java:390)
>      [exec] at com.sun.tools.javac.comp.Attr.attribTypes(Attr.java:431)
>      [exec] at
> com.sun.tools.javac.comp.Attr.visitTypeApply(Attr.java:2418)
>      [exec] at
> com.sun.tools.javac.tree.JCTree$JCTypeApply.accept(JCTree.java:1697)
>      [exec] at com.sun.tools.javac.comp.Attr.attribTree(Attr.java:360)
>      [exec] at com.sun.tools.javac.comp.Attr.attribType(Attr.java:390)
>      [exec] at com.sun.tools.javac.comp.Attr.attribBase(Attr.java:471)
>      [exec] at
> com.sun.tools.javac.comp.MemberEnter.complete(MemberEnter.java:833)
>      [exec] at com.sun.tools.javac.code.Symbol.complete(Symbol.java:384)
>      [exec] at
> com.sun.tools.javac.code.Symbol$ClassSymbol.complete(Symbol.java:766)
>      [exec] at com.sun.tools.javac.comp.Enter.complete(Enter.java:464)
>      [exec] at com.sun.tools.javac.comp.Enter.main(Enter.java:442)
>      [exec] at
> com.sun.tools.javac.main.JavaCompiler.enterTrees(JavaCompiler.java:822)
>      [exec] at
> com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:727)
>      [exec] at com.sun.tools.javac.main.Main.compile(Main.java:353)
>      [exec] at com.sun.tools.javac.main.Main.compile(Main.java:279)
>      [exec] at com.sun.tools.javac.main.Main.compile(Main.java:270)
>      [exec] at com.sun.tools.javac.Main.compile(Main.java:69)
>      [exec] at com.sun.tools.javac.Main.main(Main.java:54)
>      [exec] Result: 4
>
>
> --
> mailto:matthew@matthewadams.me <matthew@matthewadams.me>
> skype:matthewadams12
> googletalk:matthew@matthewadams.me
> http://matthewadams.me
> http://www.linkedin.com/in/matthewadams
>
> --
> You received this message because you are subscribed to the Google Groups
> "Querydsl" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to querydsl+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Timo Westkämper
Mysema Oy
+358 (0)40 591 2172
www.mysema.com

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message