My project has 3 submodules and it's project structure like the image below.
I am going to build moyamo-api-server [moyamo] by both maven and gradle.
moyamo has moyamo-event-domain and moyamo-common as dependencies, and moyamo-event-domain is one of submodules of moyamo-event-module. After I started moyamo-api-server in intellij as a maven project, though it has also gradle setting, I imported moyamo-common by importing its pom.xml (moyamo-common also has gradle), and imported moyamo-event-domain by importing build.gradle (moyamo-event-module and moyamo-event-domain don't have pom.xml). Importing meant here that "File/New/Module from Existing Source".
Basically when I reload maven in pom of moyamo-api-server, I cannot resolve net.infobank.moyamo:moyamo-event-domain:0.0.1-SNAPSHOT. After comment dependency of moyamo-event-domain in pom.xml of moyamo-api-server, pom sync works.
But when I run "mvn clean install" on terminal of moyamo-api-server, I get the error [ERROR] Failed to execute goal on project moyamo: Could not resolve dependencies for project net.infobank:moyamo:pom:0.0.1-SNAPSHOT: Could not find artifact net.infobank:moyamo-common:jar:0.0.1-SNAPSHOT -> [Help 1], and warning [WARNING] The POM for net.infobank:moyamo-common:jar:0.0.1-SNAPSHOT is missing, no dependency information available
I checked that moyamo has moyamo-common as a dependency at project structure.
It's the description so far for maven build.
When I tried to build by gradle, encountered this error.
I share POM of moyamo-api-server and 3 gradles.
moyamo-api-server / pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>net.infobank</groupId>
<artifactId>moyamo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>moyamo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR3</spring-cloud.version>
<org.mapstruct.version>1.3.1.Final</org.mapstruct.version>
<org.projectlombok.version>1.18.12</org.projectlombok.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
...
<dependency>
<groupId>net.infobank</groupId>
<artifactId>moyamo-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<!-- springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<!-- springfox-swager-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<!-- <dependency>-->
<!-- <groupId>net.infobank.moyamo</groupId>-->
<!-- <artifactId>moyamo-event-domain</artifactId>-->
<!-- <version>1.0-SNAPSHOT</version>-->
<!-- <systemPath>${basedir}/../moyamo-event-module/moyamo-event-domain/build/libs/moyamo-event-domain-1.0-SNAPSHOT.jar</systemPath>-->
<!--<!– <systemPath>${basedir}/target/lib/moyamo-event-domain-1.0-SNAPSHOT.jar</systemPath>–>-->
<!-- </dependency>-->
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
<!-- moyamo-event-domain dependency ./lib 에 추가.-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.10</version>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
<overWriteReleases>false</overWriteReleases>
<overWriteSnapshots>false</overWriteSnapshots>
<overWriteIfNewer>true</overWriteIfNewer>
<includeScope>system</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<configuration>
<rules>
<dependencyConvergence/>
</rules>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${org.projectlombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.asciidoctor</groupId>
<artifactId>asciidoctor-maven-plugin</artifactId>
<version>1.5.8</version>
<executions>
<execution>
<id>generate-docs</id>
<phase>prepare-package</phase>
<goals>
<goal>process-asciidoc</goal>
</goals>
<configuration>
<backend>html</backend>
<doctype>book</doctype>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.springframework.restdocs</groupId>
<artifactId>spring-restdocs-asciidoctor</artifactId>
<version>2.0.4.RELEASE</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>prepare-package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.outputDirectory}/static/docs
</outputDirectory>
<resources>
<resource>
<directory>
${project.build.directory}/generated-docs
</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!--rest docs end -->
</plugins>
</build>
</project>
moyamo-api-server / build.gradle
jar { enabled = false }
bootJar { enabled = true }
bootRun {enabled = true}
configurations {
developmentOnly
runtimeClasspath {
extendsFrom developmentOnly
}
}
sourceCompatibility = '1.8'
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-amqp'
implementation 'org.springframework.boot:spring-boot-starter-aop'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.springframework.cloud:spring-cloud-starter-circuitbreaker-resilience4j:1.0.2.RELEASE'
implementation 'org.springframework.amqp:spring-rabbit-test'
testImplementation 'org.springframework.amqp:spring-rabbit-test'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
developmentOnly "org.springframework.boot:spring-boot-devtools"
testImplementation 'org.springframework.security:spring-security-test'
implementation 'org.hibernate:hibernate-spatial'
implementation 'org.hibernate:hibernate-ehcache'
implementation 'org.hibernate:hibernate-search-orm'
implementation 'org.hibernate:hibernate-search-elasticsearch'
implementation 'org.apache.commons:commons-lang3:3.11'
implementation 'com.auth0:java-jwt:3.10.2'
implementation 'commons-io:commons-io:2.6'
implementation 'io.findify:s3mock_2.12:0.2.5'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign:2.2.2.RELEASE'
runtimeOnly 'mysql:mysql-connector-java:8.0.19'
testImplementation 'junit:junit:4.12'
implementation 'com.sksamuel.scrimage:scrimage-core:4.0.5'
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
implementation 'com.google.code.gson:gson:2.8.6'
}
moyamo-common / build.gradle
bootJar { enabled = false }
jar { enabled = true }
/*
* This file was generated by the Gradle 'init' task.
*/
ext {
set('springCloudVersion', "2020.0.1")
set('mapstructVersion', "1.3.1.Final")
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-aop'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.hibernate:hibernate-search-orm'
implementation 'org.hibernate:hibernate-ehcache'
implementation 'org.hibernate:hibernate-search-elasticsearch'
implementation 'org.hibernate:hibernate-spatial'
implementation 'com.bedatadriven:jackson-datatype-jts:2.2'
implementation "org.mapstruct:mapstruct"
annotationProcessor "org.mapstruct:mapstruct-processor"
testAnnotationProcessor "org.mapstruct:mapstruct-processor:"
implementation 'io.github.resilience4j:resilience4j-micrometer:1.1.0'
implementation 'io.github.resilience4j:resilience4j-metrics:1.1.0'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign:2.2.2.RELEASE'
implementation 'io.micrometer:micrometer-registry-prometheus:1.2.0'
implementation 'com.auth0:java-jwt:3.10.2'
implementation 'commons-io:commons-io:2.6'
implementation 'io.findify:s3mock_2.12:0.2.5'
implementation 'org.springframework.cloud:spring-cloud-aws-context:2.2.6.RELEASE'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.apache.shiro:shiro-all:1.2.3'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.11.0'
implementation 'org.apache.commons:commons-lang3:3.11'
implementation 'com.sksamuel.scrimage:scrimage-core:4.0.5'
implementation 'org.apache.poi:poi:4.1.2'
runtimeOnly 'mysql:mysql-connector-java:8.0.19'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.amqp:spring-rabbit-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'junit:junit:4.12'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
}
moyamo-event-module / build.gradle
bootJar { enabled = false }
jar { enabled = true }
/*
* This file was generated by the Gradle 'init' task.
*/
ext {
set('springCloudVersion', "2020.0.1")
set('mapstructVersion', "1.3.1.Final")
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-aop'
implementation 'org.springframework.boot:spring-boot-starter-data-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.hibernate:hibernate-search-orm'
implementation 'org.hibernate:hibernate-ehcache'
implementation 'org.hibernate:hibernate-search-elasticsearch'
implementation 'org.hibernate:hibernate-spatial'
implementation 'com.bedatadriven:jackson-datatype-jts:2.2'
implementation "org.mapstruct:mapstruct"
annotationProcessor "org.mapstruct:mapstruct-processor"
testAnnotationProcessor "org.mapstruct:mapstruct-processor:"
implementation 'io.github.resilience4j:resilience4j-micrometer:1.1.0'
implementation 'io.github.resilience4j:resilience4j-metrics:1.1.0'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign:2.2.2.RELEASE'
implementation 'io.micrometer:micrometer-registry-prometheus:1.2.0'
implementation 'com.auth0:java-jwt:3.10.2'
implementation 'commons-io:commons-io:2.6'
implementation 'io.findify:s3mock_2.12:0.2.5'
implementation 'org.springframework.cloud:spring-cloud-aws-context:2.2.6.RELEASE'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.apache.shiro:shiro-all:1.2.3'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.11.0'
implementation 'org.apache.commons:commons-lang3:3.11'
implementation 'com.sksamuel.scrimage:scrimage-core:4.0.5'
implementation 'org.apache.poi:poi:4.1.2'
runtimeOnly 'mysql:mysql-connector-java:8.0.19'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.amqp:spring-rabbit-test'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation 'org.springframework.security:spring-security-test'
testImplementation 'junit:junit:4.12'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
}
rootProject.name = 'moyamo-event-module'
include 'moyamo-event-domain'
include 'moyamo-event-server'
moyamo-event-module / moyamo-event-domain / build.gradle
plugins {
id 'java'
}
jar { enabled = true }
//bootJar { enabled = false}
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.6.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
compileOnly 'org.projectlombok:lombok:1.18.10'
annotationProcessor 'org.projectlombok:lombok:1.18.10'
}
test {
useJUnitPlatform()
}
I hope to have moyamo-api-server built by both Maven and Gradle.
The weird thing is that in moyamo-parent (root project), which has moyamo-api-server as a dependency, I can build entire project successfully by run "./gradlew clean build -x test" and get each project built by jar or war.
moyamo-parent has only gradle.
But moyamo-api-server cannot be built indenpendently.
So I add moyamo-parent gradle here for clear understanding my trouble.
moyamo-parent / build.grale & settings.gradle
buildscript {
ext {
springBootVersion = '2.4.7'
}
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'io.spring.dependency-management'
allprojects {
group = 'net.infobank.moyamo'
version = '0.0.1-SNAPSHOT'
}
repositories {
mavenCentral()
}
subprojects {
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
apply plugin: 'java'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
ext {
set('springCloudVersion', "2020.0.3")
set('mapstructVersion', "1.3.1.Final")
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-amqp'
implementation 'org.springframework.boot:spring-boot-starter-validation'
runtime("org.springframework.boot:spring-boot-properties-migrator")
compile("org.mapstruct:mapstruct:${mapstructVersion}")
compileOnly("org.mapstruct:mapstruct-processor:${mapstructVersion}")
annotationProcessor("org.mapstruct:mapstruct-processor:${mapstructVersion}")
implementation group: 'com.drewnoakes', name: 'metadata-extractor', version: '2.16.0'
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
implementation 'org.hibernate:hibernate-spatial:5.2.14.Final'
implementation 'org.hibernate:hibernate-ehcache:5.4.13.Final'
implementation 'org.hibernate:hibernate-search-orm:5.11.9.Final'
implementation 'org.hibernate:hibernate-search-elasticsearch:5.11.9.Final'
implementation 'org.elasticsearch.client:elasticsearch-rest-client:6.8.12'
implementation 'org.elasticsearch.client:elasticsearch-rest-client-sniffer:5.6.16'
}
task initSourceFolders {
sourceSets*.java.srcDirs*.each {
if (!it.exists()) {
it.mkdirs()
}
}
sourceSets*.resources.srcDirs*.each {
if (!it.exists()) {
it.mkdirs()
}
}
}
}
project(':moyamo') {
dependencies {
compile project(':moyamo-common')
compile project(':moyamo-event-domain')
implementation 'org.springframework.boot:spring-boot-starter-amqp'
}
}
project(':moyamo-admin') {
dependencies {
compile project(':moyamo-common')
implementation 'org.springframework.boot:spring-boot-starter-amqp'
}
}
project(':moyamo-scheduler') {
dependencies {
compile project(':moyamo-common')
compile project(':moyamo-event-domain')
implementation 'org.springframework.boot:spring-boot-starter-amqp'
}
}
//def common = project(':moyamo-common')
//def domain = project(':moyamo-event-domain')
/*configure ([common]) {
apply plugin: "io.spring.dependency-management"
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
}
}*/
rootProject.name = 'moyamo-parent'
include ':moyamo', //moyamo-api-server
':moyamo-event-domain',
':moyamo-common',
':moyamo-admin',
':moyamo-scheduler'
for (project in rootProject.children) {
project.projectDir = file("../moyamo-event-module/${project.name}")
}
project(':moyamo').setProjectDir(new File(settingsDir, '../moyamo-api-server'))
project(':moyamo-common').setProjectDir(new File(settingsDir, '../moyamo-common'))
project(':moyamo-admin').setProjectDir(new File(settingsDir, '../moyamo-admin'))
project(':moyamo-scheduler').setProjectDir(new File(settingsDir, '../moyamo-scheduler'))
I need your helps, thanks in advance.
Related
I have many spring boot microservices and I have developed a new project that has Spring-Vault as a dependency. This new project (say vault-client-spring) is developed in order to have common configuration for setting up of Vault and use it in all of the microservices and I have published the jar in private maven hosted repository in my organization.
My problem is when I add this jar as dependency in any microservices, the application is not starting throwing the following error. The Spring-Cloud-Vault dependencies are not imported to my consuming projects. I've also added the necessary properties requrired starting with prefix spring.cloud.vault in bootstrap.yml file.
Here's my build.gradle file for vault-client-spring.
group = 'com.mygroup'
version = '0.0.1'
buildscript {
ext {
springBootVersion = '2.4.4'
springDepsMgmtVersion = '1.0.11.RELEASE'
}
repositories {
mavenCentral()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}"
classpath "io.spring.gradle:dependency-management-plugin:${springDepsMgmtVersion}"
}
}
apply plugin: 'java-library'
apply plugin: 'idea'
apply plugin: 'maven-publish'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
bootJar {
enabled = false
}
jar {
archivesBaseName = 'vault-client-spring'
enabled = true
}
ext {
springCloudVersion = '2020.0.2'
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-vault-config'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier('sources')
from sourceSets.main.allSource
}
publishing {
publications {
mavenJava(MavenPublication) {
artifact jar
artifact sourcesJar
}
}
repositories {
maven {
credentials {
username 'PRIVATE-USER'
password 'PRIVATE-PASSWORD'
}
url 'PRIVATE MAVEN URL'
}
}
}
Here's the build.gradle file for a microservice using this jar.
plugins {
id 'org.springframework.boot' version '2.4.3'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
group = 'com.mygroup'
version = ''
sourceCompatibility = '1.8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
maven { url 'PRIVATE MAVEN URL' }
}
bootJar {
setArchivesBaseName("microservice-one")
version("")
}
dependencies {
implementation 'com.mygroup:vault-client-spring:0.0.1' // here's the dependency
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
compileJava {
compileJava.inputs.files(processResources)
}
test {
useJUnitPlatform()
}
The generated POM file.
<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>com.mygroup</groupId>
<artifactId>vault-client-spring</artifactId>
<version>0.0.1</version>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2020.0.2</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.4.4</version>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
</project>
The error I'm facing is as follows..
Caused by: java.io.FileNotFoundException: class path resource [org/springframework/vault/config/AbstractVaultConfiguration.class] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:180) ~[spring-core-5.3.4.jar:5.3.4]
at org.springframework.core.type.classreading.SimpleMetadataReader.getClassReader(SimpleMetadataReader.java:55) ~[spring-core-5.3.4.jar:5.3.4]
at org.springframework.core.type.classreading.SimpleMetadataReader.<init>(SimpleMetadataReader.java:49) ~[spring-core-5.3.4.jar:5.3.4]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:103) ~[spring-core-5.3.4.jar:5.3.4]
at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.createMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:86) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.getMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:73) ~[spring-boot-2.4.3.jar:2.4.3]
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:81) ~[spring-core-5.3.4.jar:5.3.4]
at org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:696) ~[spring-context-5.3.4.jar:5.3.4]
at org.springframework.context.annotation.ConfigurationClassParser$SourceClass.getSuperClass(ConfigurationClassParser.java:1010) ~[spring-context-5.3.4.jar:5.3.4]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:341) ~[spring-context-5.3.4.jar:5.3.4]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:250) ~[spring-context-5.3.4.jar:5.3.4]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:199) ~[spring-context-5.3.4.jar:5.3.4]
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:304) ~[spring-context-5.3.4.jar:5.3.4]
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:250) ~[spring-context-5.3.4.jar:5.3.4]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:207) ~[spring-context-5.3.4.jar:5.3.4]
at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:175) ~[spring-context-5.3.4.jar:5.3.4]
... 14 common frames omitted
How to solve this error? I'm working for the first time in Spring Cloud native projects
I found it myself. Since I'm developing as "library", I have to allow Spring-Vault dependencies to get included in consuming applications. As per Gradle's java-library plugin, I used api dependency. The consuming applications can able to access and bootstrap them.
i'm switching from maven to gradle.
Here is what i used to have in my pom.xml
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compilerArgument>-proc:none</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.bsc.maven</groupId>
<artifactId>maven-processor-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>process</id>
<goals>
<goal>process</goal>
</goals>
<phase>generate-sources</phase>
</execution>
<execution>
<id>process-test</id>
<goals>
<goal>process-test</goal>
</goals>
<phase>generate-test-sources</phase>
<configuration>
<sourceDirectory>./test</sourceDirectory>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>rockpalm.it</groupId>
<artifactId>ic2-annotation-processor</artifactId>
<version>1.2.1-SNAPSHOT</version>
</dependency>
</dependencies>
</plugin>
My build.gradle looks like :
plugins {
id "net.ltgt.apt" version "0.15"
id 'net.ltgt.apt-eclipse' version '0.15'
}
dependencies {
annotationProcessor "rockpalm.it:ic2-annotation-processor:1.2.1-SNAPSHOT"
}
ext {
eclipseAptFolder = '.apt_generated'
eclipseSettingsDir = file('.settings')
}
eclipse {
jdt.file.withProperties {
it['org.eclipse.jdt.core.compiler.processAnnotations'] = 'enabled'
}
}
tasks.eclipseJdt {
doFirst {
def aptPrefs = file("${eclipseSettingsDir}/org.eclipse.jdt.apt.core.prefs")
aptPrefs.parentFile.mkdirs()
aptPrefs.text = """\
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=true
org.eclipse.jdt.apt.genSrcDir=${eclipseAptFolder}
org.eclipse.jdt.apt.reconcileEnabled=true
""".stripIndent()
file('.factorypath').withWriter {
new groovy.xml.MarkupBuilder(it).'factorypath' {
project.configurations.annotationProcessor.each { dep->
factorypathentry(
kind:'EXTJAR',
id:dep.absolutePath,
enabled:true,
runInBatchMode:false
)
}
}
}
}
}
But when I use Gradle > Refresh gradle project it does not configure the .factorypath of eclipse with my annotation processor, it enables it but without setting the actual processor on the processor list.
When I run the gradle build I can actually see my generated code in build/generated/source/apt/main/...my packages/classes but since it's not enabled in eclipse I have nothing in .apt_generated folder.
EDIT
I got gradle to build the factorypath correctly with the tasks.eclipseJdt part of the build.gradle but eclipse doesn't seem to build anything in the .apt_generated still. How can I debug eclipse gradle build to see what's happening ?
Any help appreciated, Thanks
You usually don't need the eclipse configuration closure from the plugin example, just use:
plugins {
id 'net.ltgt.apt' version '0.15'
id 'net.ltgt.apt-eclipse' version '0.15'
}
dependencies {
annotationProcessor 'rockpalm.it:ic2-annotation-processor:1.2.1-SNAPSHOT'
}
Execute gradle eclipse to setup the factory path and refresh the project in Eclipse.
Given a Gradle web project that is to be published as a JAR (so that it can be a dependency of another Gradle web project, which has a different release cycle).
The maven-publish plugin is used:
apply plugin: 'war'
apply plugin: 'maven'
apply plugin: 'maven-publish'
The web project has a providedCompile dependency:
providedCompile 'javax.servlet:javax.servlet-api:3.0.1'
A jar is published using mavenJava:
publishing {
publications {
// mavenJava publishes a jar file
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
mavenLocal()
}
}
The problem is that javax.servlet-api has a runtime scope in the resulting Maven POM:
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>runtime</scope>
</dependency>
Runtime scope makes no sense for the servlet-api, it is even harmful. How can the scope be set to provided in the pom.xml?
With the help of pom.withXml (see this Gradle sample) it's possible to transform Gradle's providedCompile into provided scope for Maven's POM:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
// providedCompile -> provided scope
pom.withXml {
asNode().dependencies.'*'.findAll() {
it.scope.text() == 'runtime' && project.configurations.providedCompile.allDependencies.find { dep ->
dep.name == it.artifactId.text()
}
}.each() {
it.scope*.value = 'provided'
}
}
}
}
repositories {
mavenLocal()
}
}
What the pom.withXml section does is going through all dependencies of type providedCompile within the Gradle project configuration and changing the scope to be written into the Maven pom.xml from runtime to provided.
The generated pom.xml now has the provided scope set for the javax.servlet-api:
<project xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
[...]
<dependencies>
[...]
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
I have a multi-project setup in maven and trying to switch to gradle. I am trying to figure out how to have one project's test dependencies include another project's test jar. Right now i have the following in ProjectA:
packageTests = task packageTests(type: Jar) {
classifier = 'tests'
from sourceSets.test.output
}
tasks.getByPath(":ProjectA:jar").dependsOn(packageTests)
And in ProjectB i have:
testCompile project(path: ':ProjectA', classifier: 'tests')
I see that my tests are failing to compile. Looks like they are missing classes defined in the test jar. When I check the build dir, i see that the ProjectA-0.1.56-SNAPSHOT-tests.jar is present.
In maven I had the following for ProjectA:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
And this for ProjectB:
<!-- Testing -->
<dependency>
<groupId>com.example</groupId>
<artifactId>ProjectA</artifactId>
<version>0.1.56-SNAPSHOT</version>
<type>test-jar</type>
</dependency>
How can I get this to work just like maven?
What you will end up with is something like
tasks.create( [
name: 'testJar',
type: Jar,
group: 'build',
description: 'Assembles a jar archive containing the test classes.',
dependsOn: tasks.testClasses
] ) {
manifest = tasks.jar.manifest
classifier = 'tests'
from sourceSets.test.output
}
// for test dependencies between modules
// usage: testCompile project(path: ':module', configuration: 'testFixtures')
configurations { testFixtures { extendsFrom testRuntime } }
artifacts {
archives testJar
testFixtures testJar
}
tasks.uploadArchives.dependsOn testJar
I banged my head for two days to integrate aspectj with maven, But did not work.
I am writing a simple program with two advices (which works fine in eclipse, so I am sure it's not a code side error).
I have recently started using maven for project building. Can't think of why I am not able to kick off aspectj compiler.
During compilation through maven - I get only class file for java without weaving. .aj file is not compiled.
Please Help!!!!
the first aspect file - ExceptionAspects.aj
package com.aspectSample;
public aspect ExceptionAspects {
pointcut ExceptionHandler(Exception e) : handler(Exception+) && args(e) && within(com.clickable.*);
pointcut callbeforeMethod():execution( public void HelloWorldExclude.*(..)) ;
before(Exception ex) : ExceptionHandler(ex)
{
System.out.println("Added Aspects before Exception :"+ex.toString());
}
before(): callbeforeMethod()
{
System.out.println("Aspect Before Method Call");
}
pointcut sysOutOrErrAccess() : get(* System.out) || get(* System.err);
declare error
: sysOutOrErrAccess()
: "Don't write to the console";
}
The source java file HelloWorldExclude.java
package com.aspectSample;
import java.sql.SQLException;
public class HelloWorldExclude {
private void FoulIntro(String message, String name) throws SQLException
{
throw new SQLException("WriteSomething");
}
public void GiveMeFoulIntro(String message, String name)
{
try
{
this.FoulIntro(message, name);
}catch(SQLException exp)
{
System.out.println("catching exception");
}
}
}
and the pom.xml file is
<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>com.clickable.HelloWorld-Maven</groupId>
<artifactId>HelloWorldAspect-Maven</artifactId>
<version>1.0.0</version>
<name>HelloWorld Aspect</name>
<packaging>jar</packaging>
<description>Hello World Code</description>
<properties>
<java-version>1.6</java-version>
<org.aspectj-version>1.6.11</org.aspectj-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${org.aspectj-version}</version>
</dependency>
</dependencies>
</project>
A couple of things that you can try:
Explicitly provide the dependencies of the maven-aspectj plugin:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.4</version>
<dependencies>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>${aspectj.version}</version>
</dependency>
</dependencies>
with the version of aspectjrt and aspectjtools matching the version of aspectj that you are using.
Do you by any chance have any of your sources in the test folder,
with the src/test folder, then to weave the aspects to the test sources you will have to explicitly mention that in the maven-aspectj plugin:
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
There was a stupid mistake in pom file.
aspectj plugin was added under element, which is just a configuration of all plugins. It doesn't tell compiler what to use.
It worked as soon as I removed plugin out of this element.
Thanks
Pankaj