Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java

Thossaporn Itngam
Thossaporn Itngam
2,348 Points

how to change maven to gradle of querydsl

i am following : https://github.com/querydsl/querydsl/tree/master/querydsl-jpa

normally, i use gradle for load dependency but it's not enough. now i suspect about how to use plugin of gradle.

how can i change maven script below to gradle and advice me more detail about this.

thanks.

<project>
  <build>
    <plugins>
      ...
      <plugin>
        <groupId>com.mysema.maven</groupId>
        <artifactId>apt-maven-plugin</artifactId>
        <version>1.1.3</version>
        <executions>
          <execution>
            <goals>
              <goal>process</goal>
            </goals>
            <configuration>
              <outputDirectory>target/generated-sources/java</outputDirectory>
              <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
            </configuration>
          </execution>
        </executions>
        <dependencies>
          <dependency>
            <groupId>com.querydsl</groupId>
            <artifactId>querydsl-apt</artifactId>
            <version>${querydsl.version}</version>
          </dependency>
        </dependencies>
      </plugin>
      ...
    </plugins>
  </build>
</project>

2 Answers

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,161 Points

What you are looking for is Gradle Plugin for QueryDsl.

See GitHub repo here

Important thing is to incorporate your generated classes so that Intellijdea can for example help you build QueryDsl queries.

This here is one of the examples...

I've done it once, but don't have example at hand. When I have time I will try to compile info and post here...

One thing I remember that was Super Important.

Do NOT check 'Create Separate module per source set'. This way you screw things up. For more on this read here

Thossaporn Itngam
Thossaporn Itngam
2,348 Points

yes, but i am trying to follow this : http://www.querydsl.com/static/querydsl/latest/reference/html/ch02.html#jpa_integration

and i dont know how to migrate maven to gradle

<project>
  <build>
  <plugins>
    ...
    <plugin>
      <groupId>com.mysema.maven</groupId>
      <artifactId>apt-maven-plugin</artifactId>
      <version>1.1.3</version>
      <executions>
        <execution>
          <goals>
            <goal>process</goal>
          </goals>
          <configuration>
            <outputDirectory>target/generated-sources/java</outputDirectory>
            <processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
          </configuration>
        </execution>
      </executions>
    </plugin>
    ...
  </plugins>
  </build>
</project>
Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,161 Points

Please forget about converting maven to Gradle. You cannot simply convert.

Maven use its own plugin in own way, Gradle uses its own plugin in its own way.

Please follow the links in the answer.

Your Gradle as you can see here

Please follow that link ...

So in the GitHub repo you see that in the end your build.gradle will looks somewhat like that (The example below is for MongoDb, taken from GitHub repo of Gradle Plugin)

plugins {
  id "com.ewerk.gradle.plugins.querydsl" version "1.0.8"
}

repositories {
  mavenCentral()
}

dependencies {
  […]
  // make MongoDB annotation processor available at classpath
  compile "org.springframework.data:spring-data-mongodb:1.9.1.RELEASE"

  // use Querydsl against MongoDB
  compile "com.querydsl.apt:querydsl-mongodb:4.1.3"
  […]
}

querydsl {
  springDataMongo = true
}