Can't build or package kotlin maven based spring boot project - spring

I have a kotlin spring boot project, this project is my first example in kotlin that I have developed.
I use jpa and metamodel for building queries. when I try to build the project I encounter with "cannot find symbol" error message.
I attached the here the source code.
can anyone build my source code and find my exact point of failure.
I also added Employee entity , Repository classes and pom file context.
#Entity
#Table(name = "tblEmployees")
open class Employee : Serializable {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
#Column(name = "employeeId", unique = false, nullable = false)
var employeeId: Long? = null ;
#Column(name = "EmployeeGuid", unique = true, nullable = false, length = 20)
var employeeGuid: String? = null
#Column(name = "FirstName", unique = false, nullable = false, length = 20)
var firstName: String? = null
#Column(name = "LastName", unique = false, nullable = false, length = 20)
var lastName: String? = null
#Column(name = "Role", unique = false, nullable = false, length = 20)
var role: String? = null
#Column(name = "RegisterServerIP", unique = false, nullable = false, length = 20)
var registerServerIP: String? = null
#Column(name = "RegisterClientIP", unique = false, nullable = false, length = 20)
var registerClientIP: String? = null
#Column(name = "RegisterDate", nullable = false)
var registerDate: Int? = null
#Column(name = "RegisterTime", nullable = false, length = 8)
var registerTime: String? = null
#Column(name = "RegisterDateComplete", nullable = false, length = 50)
var registerDateComplete: String? = null
}
#Repository
interface RepoEmployee : JpaRepository<Employee, Long>, RepoEmployeeExtension {
fun findByFirstName(firstName: String): List<Employee> // default implementation
fun findByLastName(lastName: String): List<Employee> // default implementation
#Query("select e from Employee e where e.firstName like %:firstName%") // default implementation
fun findContains(#Param("firstName") firstName: String): List<Employee>
}
#Repository
interface RepoEmployeeExtension {
fun findInRange(from: Int, to: Int): List<Employee>
fun findEmployeeByIdOnNQ(id: Long): Employee?
fun searchEmployees(startIndex: Int, endIndex: Int ,employeeId: Long? , firstName: String? , lastName: String? , role: String? , registerDate : Int? , registerClientIP : String? ,
registerUserId: Long? , registerUserName: String? ): List<Employee>
}
class RepoEmployeeExtensionImpl : RepoEmployeeExtension {
#Autowired
private lateinit var entityManager: EntityManager
override fun findInRange(from: Int, to: Int): List<Employee> {
val builder = entityManager.getCriteriaBuilder()
val query = builder.createQuery(Employee::class.java)
val root = query.from(Employee::class.java)
query.select(root)
val q = entityManager.createQuery(query)
q.firstResult = from
q.maxResults = to
return q.resultList
}
override fun findEmployeeByIdOnNQ(id: Long): Employee? {
var employee = entityManager.createNamedQuery("NQfindEmployeeByCId").setParameter("id", id).resultList.stream().findFirst()
return employee as? Employee; // nullable cast
}
override fun searchEmployees(startIndex: Int, endIndex: Int , employeeId: Long?, firstName: String?, lastName: String?, role: String?, registerDate: Int?, registerClientIP: String?,
registerUserId: Long?, registerUserName: String?): List<Employee> {
val criteriaBuilder = entityManager.getCriteriaBuilder()
val query = criteriaBuilder.createQuery<Employee>(Employee::class.java)
val rootEmployee: Root<Employee> = query.from(Employee::class.java)
//Convert LazyLoad to eager in criteriaBuilder
// val rootArUserJoin= rootEmployee.join(Employee_.current_registerUser , JoinType.INNER)
// val rootArUserFetch= rootEmployee.fetch(Employee_.current_registerUser , JoinType.INNER)
val criterias = ArrayList<Predicate>()
if (employeeId != null && employeeId != -1L) {
criterias.add(criteriaBuilder.equal(rootEmployee.get(Employee_.employeeId), employeeId))
}
if (!firstName.isNullOrEmpty()) {
criterias.add(criteriaBuilder.like(rootEmployee.get(Employee_.firstName), firstName))
}
if (!lastName.isNullOrEmpty()) {
criterias.add(criteriaBuilder.like(rootEmployee.get(Employee_.lastName), lastName))
}
if (!role.isNullOrEmpty()) {
criterias.add(criteriaBuilder.like(rootEmployee.get(Employee_.role), role))
}
if (registerDate != null && registerDate != -1) {
criterias.add(criteriaBuilder.equal(rootEmployee.get(Employee_.registerDate), registerDate))
}
if (!registerClientIP.isNullOrEmpty()) {
criterias.add(criteriaBuilder.equal(rootEmployee.get(Employee_.registerClientIP), registerClientIP))
}
// if (registerUserName != null && !registerUserName.isEmpty()) {
// criterias.add(criteriaBuilder.equal(rootArUserJoin.get(ArUser_.userName), registerUserName));
// }
// if (registerUserId != null && registerUserId != -1L) {
// criterias.add(criteriaBuilder.equal(rootArUserJoin.get(ArUser_.userId), registerUserId));
// }
// val rootArUserJoin= rootEmployee.join(Employee_.current_registerUser , JoinType.INNER)
// val rootArUserFetch= rootEmployee.fetch(Employee_.current_registerUser , JoinType.INNER)
//
// val criterias = ArrayList<Predicate>()
// if (employeeId != null && employeeId != -1L) {
// criterias.add(criteriaBuilder.equal(rootEmployee.get(Employee_.employeeId), employeeId))
// }
// if (!firstName.isNullOrEmpty()) {
// criterias.add(criteriaBuilder.like(rootEmployee.get(Employee_.firstName), firstName))
// }
// if (!lastName.isNullOrEmpty()) {
// criterias.add(criteriaBuilder.like(rootEmployee.get(Employee_.lastName), lastName))
// }
// if (!role.isNullOrEmpty()) {
// criterias.add(criteriaBuilder.like(rootEmployee.get(Employee_.role), role))
// }
// if (registerDate != null && registerDate != -1) {
// criterias.add(criteriaBuilder.equal(rootEmployee.get(Employee_.registerDate), registerDate))
// }
// if (!registerClientIP.isNullOrEmpty()) {
// criterias.add(criteriaBuilder.equal(rootEmployee.get(Employee_.registerClientIP), registerClientIP))
// }
// if (registerUserName != null && !registerUserName.isEmpty()) {
// criterias.add(criteriaBuilder.equal(rootArUserJoin.get(ArUser_.userName), registerUserName));
// }
// if (registerUserId != null && registerUserId != -1L) {
// criterias.add(criteriaBuilder.equal(rootArUserJoin.get(ArUser_.userId), registerUserId));
// }
query.select(rootEmployee).where(*criterias.toTypedArray())
val q = entityManager.createQuery(query)
q.firstResult = startIndex
q.maxResults = endIndex
val results = q.getResultList()
// for (employee in results) {
// println(employee.firstName + " - " + employee.lastName )
// }
return results
}
}
<plugins>
<plugin>
<groupId>org.apache.avro</groupId>
<artifactId>avro-maven-plugin</artifactId>
<version>1.8.2</version>
<executions>
<execution>
<id>schemas</id>
<phase>generate-sources</phase>
<goals>
<goal>schema</goal>
<goal>protocol</goal>
<goal>idl-protocol</goal>
</goals>
<configuration>
<sourceDirectory>${project.basedir}/src/main/resources/avro-schemas</sourceDirectory>
<outputDirectory>${project.basedir}/src/main/kotlin/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>xjc</id>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${project.basedir}/src/main/resources</schemaDirectory>
<outputDirectory>${project.basedir}/src/main/kotlin</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>${kotlin.version}</version>
<configuration>
<args>
<arg>-Xjsr305=strict</arg>
</args>
<compilerPlugins>
<plugin>spring</plugin>
<plugin>jpa</plugin>
<plugin>all-open</plugin>
</compilerPlugins>
<pluginOptions>
<option>all-open:annotation=javax.persistence.Entity</option>
<option>all-open:annotation=javax.persistence.Embeddable</option>
<option>all-open:annotation=javax.persistence.MappedSuperclass</option>
</pluginOptions>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-noarg</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>kapt</id>
<goals>
<goal>kapt</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>src/main/kotlin</sourceDir>
</sourceDirs>
<annotationProcessorPaths>
<annotationProcessorPath>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${project.parent.version}</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.3.15.Final</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>2.2.4</version>
<configuration>
<outputDirectory>${project.basedir}/target/generated-sources/</outputDirectory>
</configuration>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<processors>
<processor>org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor</processor>
</processors>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>5.3.15.Final</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>target/generated-sources/</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<id>build-info</id>
<goals>
<goal>build-info</goal>
</goals>
<configuration>
<additionalProperties>
<build.number>${buildNumber}</build.number>
</additionalProperties>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>buildnumber</id>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<format>{0,number}</format>
<items>
<item>buildNumber</item>
</items>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>unknownbuild</revisionOnScmFailure>
</configuration>
</plugin>
</plugins>

You have to use the Kotlin compiler plugin with the jpa-plugin to make Kotlin and JPA generated Metamodel work:
<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<version>1.2.30</version>
<configuration>
<compilerPlugins>
<plugin>jpa</plugin>
</compilerPlugins>
<jvmTarget>1.8</jvmTarget>
</configuration>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-noarg</artifactId>
<version>1.2.30</version>
</dependency>
</dependencies>
<!--...-->
</plugin>
Please read more about JPA and Kotlin here: https://www.baeldung.com/kotlin-jpa

Related

openapi codegen-maven-plugin eliminate suffix UsingGET in generated methods

I'm trying to generate interfaces from yaml file with openapi codegen-maven-plugin every thing is good except the generated methods having the suffix UsingGET as you can see in this exemple bellow :
ResponseEntity<ApicatControl> retrieveRepeatedProductOfferingUsingGET(
#Parameter(name = "category.id", description = "category.id", schema = #Schema(description = "")) #Valid #RequestParam(value = "category.id", required = false) String categoryId,
#Parameter(name = "type", description = "type", schema = #Schema(description = "")) #Valid #RequestParam(value = "type", required = false) String type
);
And this is my configuration for codegen-maven-plugin within pom.xml.
<plugins>
<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
<version>5.4.0</version>
<executions>
<execution>
<id>openapi-codegen-java-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${project.basedir}/src/main/resources/swagger/swagger.yaml</inputSpec>
<generatorName>spring</generatorName>
<generateApiTests>false</generateApiTests>
<modelPackage>com.groupe.apicat.gu.api.resources.model</modelPackage>
<apiPackage>com.groupe.apicat.gu.api</apiPackage>
<output>${generated-sources-path}</output>
<templateDirectory>src/templates/service</templateDirectory>
<generateSupportingFiles>false</generateSupportingFiles>
<generateModels>true</generateModels>
<configOptions>
<skipDefaultInterface>true</skipDefaultInterface>
<interfaceOnly>true</interfaceOnly>
<sourceFolder>generated-sources</sourceFolder>
<dateLibrary>legacy</dateLibrary>
<returnResponse>true</returnResponse>
<library>spring-boot</library>
<useTags>true</useTags>
<hideGenerationTimestamp>true</hideGenerationTimestamp>
<useSwaggerAnnotations>true</useSwaggerAnnotations>
<serializableModel>true</serializableModel>
<delegatePattern>false</delegatePattern>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
Please do you have any solutions!! thanks
The method name "retrieveRepeatedProductOfferingUsingGET" is created within your swagger.yaml. There should be a parameter called "operationId" where you specify this name. So just change it there and build the project again.

Micronaut-data : No current JDBC Connection found. Consider wrapping this call in transactional boundaries

I am getting No current JDBC Connection found. exception while using micronaut-data, i am referring to https://github.com/tdisanti/micronaut-single-ucp
micronaut version
<micronaut.version>2.0.0</micronaut.version>
<micronaut.data.version>1.1.1</micronaut.data.version>
logs:
2020-07-02 19:03:30.716 [nioEventLoopGroup-1-3] ERROR i.m.h.s.netty.RoutingInBoundHandler:1839- Unexpected error occurred: No current JDBC Connection found. Consider wrapping this call in transactional boundaries.
io.micronaut.transaction.jdbc.exceptions.CannotGetJdbcConnectionException: No current JDBC Connection found. Consider wrapping this call in transactional boundaries.
at io.micronaut.transaction.jdbc.DataSourceUtils.doGetConnection(DataSourceUtils.java:135)
at io.micronaut.transaction.jdbc.DataSourceUtils.getConnection(DataSourceUtils.java:93)
at io.micronaut.transaction.jdbc.DataSourceTransactionManager.getConnection(DataSourceTransactionManager.java:342)
at io.micronaut.transaction.jdbc.DataSourceTransactionManager.getConnection(DataSourceTransactionManager.java:88)
at io.micronaut.data.jdbc.operations.DefaultJdbcRepositoryOperations.prepareStatement(DefaultJdbcRepositoryOperations.java:1185)
java
#JdbcRepository(dialect = Dialect.ORACLE)
public class BooksDao {
private final JdbcOperations jdbcOperations;
#Inject
public BooksDao (JdbcOperations jdbcOperations) {
this.jdbcOperations = jdbcOperations;
}
#Transactional
public List<Book> get(){
...
}
}
yml properties
datasources:
default:
validationQuery: SELECT 1 FROM DUAL
driverClass: oracle.jdbc.driver.OracleDriver
url: jdbc:oracle:thin:<url>,cn=OracleContext,dc=uk,dc=csfb,dc=com
autoCommit: true
connectionTestQuery: SELECT 1 FROM DUAL
leakDetectionThreshold: 180000
poolName: hikariConnectionPoolName
maximumPoolSize: 10
minimumIdle: 5
data-source-properties:
truststore: '${client.truststore.path}'
truststore.password: '${client.truststore.password}'
truststore.type: JKS
keystore: '${client.keystore.path}'
keystore.password: '${client.keystore.password}'
keystore.type: PKCS12
dialect: ORACLE
DatasourceConfiguration.java
#Singleton
public class DatasourceConfiguration implements BeanCreatedEventListener<DatasourceConfiguration> {
#Override
public DatasourceConfiguration onCreated(BeanCreatedEvent<DatasourceConfiguration> event) {
LOGGER.info("Overriding DatasourceConfiguration Properties...");
DatasourceConfiguration bean = event.getBean();
Properties dataSourceProperties = bean.getDataSourceProperties();
Map<String, String> props = new HashMap<>();
props.put("javax.net.ssl.keyStore",dataSourceProperties.getProperty("keystore"));
props.put("javax.net.ssl.keyStorePassword",dataSourceProperties.getProperty("keystore.password"));
props.put("javax.net.ssl.keyStoreType",dataSourceProperties.getProperty("keystore.type"));
props.put("javax.net.ssl.trustStore",dataSourceProperties.getProperty("truststore"));
props.put("javax.net.ssl.trustStorePassword",dataSourceProperties.getProperty("truststore.password"));
props.put("javax.net.ssl.trustStoreType",dataSourceProperties.getProperty("truststore.type"));
props.put("oracle.net.authentication_services","(TCPS)");
props.put("oracle.net.ssl_client_authentication","TRUE");
props.put("ssl.keyManagerFactory.algorithm","SunX509");
props.put("oracle.net.ssl_cipher_suites","(TLS_RSA_WITH_AES_256_CBC_SHA)");
props.put("oracle.net.encryption_client","REJECTED");
props.put("oracle.net.crypto_checksum_client","REJECTED");
bean.setDataSourceProperties(props);
return bean;
}
}
The issue get resolved by adding micronaut-data-processor in annotationProcessorPaths of maven-compiler-plugin.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<release>${jdk.version}</release>
<encoding>UTF-8</encoding>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject-java</artifactId>
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-validation</artifactId>
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut.configuration</groupId>
<artifactId>micronaut-openapi</artifactId>
<version>${micronaut.openapi.version}</version>
</path>
<path>
<groupId>io.micronaut.data</groupId>
<artifactId>micronaut-data-processor</artifactId>
<version>1.0.2</version>
</path>
</annotationProcessorPaths>
</configuration>
<executions>
<execution>
<id>test-compile</id>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<compilerArgs>
<arg>-parameters</arg>
</compilerArgs>
<annotationProcessorPaths>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-inject-java</artifactId>
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut</groupId>
<artifactId>micronaut-validation</artifactId>
<version>${micronaut.version}</version>
</path>
<path>
<groupId>io.micronaut.configuration</groupId>
<artifactId>micronaut-openapi</artifactId>
<version>${micronaut.openapi.version}</version>
</path>
<path>
<groupId>io.micronaut.data</groupId>
<artifactId>micronaut-data-processor</artifactId>
<version>1.0.2</version>
</path>
</annotationProcessorPaths>
</configuration>
</execution>
</executions>
</plugin>
</plugins>

Not able to link my javadocs with spring auto rest docs

I am not getting how do you use JavaDocs, with Spring Auto Rest Docs. I can generate my java-docs locally by using STS, UI option. However,i am not sure how to generate java-docs using Spring Auto Rest Docs. I tried writing some plugin in POM. But the auto-description.adoc and many other doc are still empty.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
<extensions>true</extensions>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<!-- switch on dependency-driven aggregation -->
<includeDependencySources>true</includeDependencySources>
</configuration>
</execution>
<execution>
<id>generate-javadoc-json</id>
<phase>compile</phase>
<goals>
<goal>javadoc-no-fork</goal>
</goals>
<configuration>
<doclet>capital.scalable.restdocs.jsondoclet.ExtractDocumentationAsJsonDoclet</doclet>
<docletArtifact>
<groupId>capital.scalable</groupId>
<artifactId>spring-auto-restdocs-json-doclet</artifactId>
</docletArtifact>
<additionalparam>
-d ${project.build.directory}/site/doccheck
</additionalparam>
<reportOutputDirectory>${project.build.directory}</reportOutputDirectory>
<useStandardDocletOptions>false</useStandardDocletOptions>
<show>package</show>
</configuration>
</execution>
</executions>
</plugin>
Basically I am not getting how to make Spring Auto Rest Docs use Java Docs to find Path Parameters. I can use mvn javadoc:javadoc command on terminal to create Javadocs whch are created in target/site/apidocs/ folder. But I still get No parameters in my auto-path-parameters.adoc
Here is the controller, I am using GraphQL so its different:
/**
* Query Controller Class
* #author shantanu
*
*/
#RestController
#RequestMapping(value="/graphql")
public class QueryController {
#Value("classpath:/graphql/actionItm.graphqls")
private Resource schemaResource;
private GraphQL graphQL;
#Autowired
#Qualifier("graphQLDate")
private GraphQLScalarType Date;
#Autowired
private AllActionItemsDataFetcher allActionItemsDataFetcher;
#Autowired
private ActionItemDataFetcher actionItemDataFetcher;
#Autowired
private PageActionItemDataFetcher pageActionItemDataFetcher;
#PostConstruct
public void loadSchema() throws IOException {
File schemaFile = schemaResource.getFile();
TypeDefinitionRegistry typeRegistry = new SchemaParser().parse(schemaFile);
RuntimeWiring wiring = buildRuntimeWiring();
GraphQLSchema schema = new SchemaGenerator().makeExecutableSchema(typeRegistry, wiring);
graphQL = GraphQL.newGraphQL(schema).build();
}
private RuntimeWiring buildRuntimeWiring() {
return RuntimeWiring.newRuntimeWiring()
.type("Query", typeWiring -> typeWiring
.dataFetcher("findAllActionItems", allActionItemsDataFetcher)
.dataFetcher("findActionItem", actionItemDataFetcher)
.dataFetcher("pageActionItems", pageActionItemDataFetcher))
.scalar(Date)
.build();
}
/**
* This
* #param query Description
* #return ResponseEntity responseEntity
*/
#PostMapping
public ResponseEntity query(#RequestBody String query) {
ExecutionResult result = graphQL.execute(query);
return ResponseEntity.ok(result.getData());
}
}
I am not getting where I am wrong, with the path-parameters. And only the .adoc files are generated with Spring Auto Rest Docs, and no JSON files.

QueryDslPredicateExecutor Q-class is not generating

My Pom file is
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-apt</artifactId>
<version>4.0.6</version>
</dependency>
<dependency>
<groupId>com.querydsl</groupId>
<artifactId>querydsl-jpa</artifactId>
<version>4.0.6</version>
</dependency>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>process</goal>
</goals>
<configuration>
<outputDirectory>target/generated-sources</outputDirectory>
<processor>com.querydsl.apt.jpa.JPAAnnotationProcessor</processor>
</configuration>
</execution>
</executions>
</plugin>
After adding those dependency and plugin in pom.xml, I ran mvn clean install, QAutoManifest is not generating. I am new to jpa, Please help me.
public interface AutoManifestRepository extends CrudRepository<AutoManifest,String>,QueryDslPredicateExecutor<AutoManifest>{
}
And my Predicate class is
public class AutoManifestPredicate {
private AutoManifestPredicate() {
System.out.println("Predicate Object gets created");
}
static Predicate searchAutoManifest(SearchAutoManifest manifest) {
return null;
}
}

Maven plugin - modifying configuration of another plugin

I'm developing custom maven plugin.
My plugin requires a specific configuration for the surefire plugin. As result, as part of my MOJO I'm searching for 'surefire' and if it is present I'm trying to modify its configuration.
My problem is that the configuration is not used.
Here's most of my code:
package io.kuku.agents.plugin;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
/**
* Initialize the integration with the Testing Framework.
*
* #phase test
* #goal initialize-test-listener
* #since 1.0.0
*/
public class SetupMojo extends AbstractKukusMojo {
boolean hasJunit = false;
boolean hasTestNG = false;
public void execute() throws MojoExecutionException, MojoFailureException {
analyzeDependencies();
Plugin surefirePlugin = lookupPlugin("org.apache.maven.plugins:maven-surefire-plugin");
Object config = updateConfiguration(hasJunit, hasTestNG, surefirePlugin.getConfiguration());
surefirePlugin.setConfiguration(config);
List<PluginExecution> executions = surefirePlugin.getExecutions();
for (PluginExecution execution : executions) {
if (execution.getId().equals("default-test")) {
System.out.println("Setting DEFAULT-TEST");
config = updateConfiguration(hasJunit, hasTestNG, execution.getConfiguration());
execution.setConfiguration(config);
break;
}
}
}
private void analyzeDependencies() {
List dependencies = this.project.getDependencies();
for (int i = 0; i < dependencies.size(); i++) {
Dependency dependency = (Dependency) dependencies.get(i);
if (dependency.getArtifactId().equalsIgnoreCase("junit")) {
hasJunit = true;
if (hasJunit && hasTestNG)
break;
else
continue;
}
if (dependency.getArtifactId().equalsIgnoreCase("testng")) {
hasTestNG = true;
if (hasJunit && hasTestNG)
break;
else
continue;
}
}
}
private Object updateConfiguration(boolean hasJunit, boolean hasTestNG, Object configuration) throws MojoExecutionException {
if (configuration == null)
configuration = new Xpp3Dom("configuration");
if (configuration instanceof Xpp3Dom) {
Xpp3Dom xml = (Xpp3Dom) configuration;
Xpp3Dom properties = xml.getChild("properties");
if (properties == null)
{
properties = new Xpp3Dom("properties");
xml.addChild(properties);
}
Xpp3Dom[] property = properties.getChildren("property");
//My logic goes here
...
...
}
return configuration;
}
}
I'll appreciate your help.
N.
EDIT - This is my parent pom:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>sllistenertest</groupId>
<artifactId>parent-artifact</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>Sl Listener Test (Parent)</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>io.kuku.on-premise.agents.plugin</groupId>
<artifactId>kuku-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<customerid>nadav2</customerid>
<server>https://fake.kuku.co/api</server>
<appName>fake-app-name</appName>
<moduleName>fake-module-name</moduleName>
<workspacepath>${project.basedir}</workspacepath>
<build>52</build>
<branch>fake-branch</branch>
<packagesincluded>*fklistenertest*</packagesincluded>
<packagesexcluded>com.fake.excluded.*</packagesexcluded>
<filesincluded>*.class</filesincluded>
<logLevel>INFO</logLevel>
<logFolder>c:\fake-log-folder</logFolder>
<logToFile>true</logToFile>
<logEnabled>true</logEnabled>
</configuration>
<executions>
<execution>
<id>a1</id>
<goals>
<goal>build-scanner</goal>
</goals>
</execution>
<execution>
<id>a2</id>
<goals>
<goal>test-listener</goal>
</goals>
</execution>
<execution>
<id>a3</id>
<goals>
<goal>initialize-test-listener</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<!--<configuration>
<properties>
<property>
<name>listener</name>
<value>io.kuku.onpremise.agents.java.agent.integrations.testng.TestListener</value>
</property>
</properties>
<additionalClasspathElements>
<additionalClasspathElement>C:\Temp\kuku-java-1.3.160\artifacts\kuku-api-1.3.160.jar</additionalClasspathElement>
</additionalClasspathElements>
</configuration>-->
<executions>
<execution>
<id>default-test</id>
<phase>none</phase>
</execution>
<execution>
<id>run-after-antrun</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<executions>
<execution>
<id>default-test</id>
<phase>none</phase>
</execution>
<execution>
<id>run-after-antrun</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<modules>
<module>Only Junit</module>
<module>Only TestNG</module>
<module>Both</module>
</modules>
</project>
This is the pom for one of the children:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>sllistenertest</groupId>
<artifactId>parent-artifact</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>sllistenertest</groupId>
<artifactId>onlyjunit</artifactId>
<version>1.0-SNAPSHOT</version>
<name>Only JUnit</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.kuku.on-premise.agents.plugin</groupId>
<artifactId>kuku-maven-plugin</artifactId>
<version>1.0.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
</plugin>
</plugins>
</build>
</project>
You should take a look here:
for JUnit
https://maven.apache.org/surefire/maven-surefire-plugin/examples/junit.html#Using_Custom_Listeners_and_Reporters
For TestNG:
https://maven.apache.org/surefire/maven-surefire-plugin/examples/testng.html#Using_Custom_Listeners_and_Reporters
So i don't see the requirement to implement a plugin...

Resources