I am trying to use jcabi for logging. As I understand it is easier to inherit my pom from jcabi pom file for setup as described at http://www.jcabi.com/parent/index.html
However I get following error error on "mvn clean install" (has to do with resolving version number)
Any idea on how to resolve this or is it not recommended to inherit from jcabi pom file
[ERROR] Failed to execute goal org.codehaus.mojo:buildnumber-maven-plugin:1.2:
create (jcabi-build-number) on project cbm: Execution jcabi-build-number of
goalorg.codehaus.mojo:buildnumber-maven-plugin:1.2:create failed: Plugin org.codehaus
.mojo:buildnumber-maven-plugin:1.2 or one of its dependencies could not be resol
ved:
Failed to collect dependencies at org.codehaus.mojo:buildnumber-maven-plugi
n:jar:1.2 -> org.apache.maven.scm:maven-scm-api:jar:1.8 -> org.codehaus.plexus:p
lexus-utils:jar:3.0.3:
Failed to read artifact descriptor for org.codehaus.plexu
s:plexus-utils:jar:3.0.3: Could not transfer artifact org.codehaus.plexus:plexus
-utils:pom:3.0.3 from/to internal ....
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal o
rg.codehaus.mojo:buildnumber-maven-plugin:1.2:create (jcabi-build-number) on pro
ject cbm: Execution jcabi-build-number of goal org.codehaus.mojo:buildnumber-mav
en-plugin:1.2:create failed: Plugin org.codehaus.mojo:buildnumber-maven-plugin:1
2 or one of its dependencies could not be resolved:
Failed to collect dependencies at org.codehaus.mojo:buildnumber-maven-plugin:jar:1.2
-> org.apache.maven.sc
Posting answer here if relevant to any one
< dependencies>
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-aspects</artifactId>
<version>0.12</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjrt</artifactId>
<version>1.6.12</version>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-maven-plugin</artifactId>
<version>0.8</version>
<executions>
<execution>
<goals>
<goal>ajc</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
Related
I took an older Java 11, Spring based multi module project that I didn't work on since about two years and tried to make it compile and run on my new laptop. It worked on my old laptop, but I can't make it run on the new laptop. When running mvn clean install the module called "util" compiles fine. But the "shared" module, which requires the "util" module, does not find the util module: "cannot find symbol". What happens is that all the fxml and image files are copied to the target directory but there is not a single class file. Because the information about the issue was very limited in STS (Spring development tool) I installed Maven 3.8.2. and tried to fix it from the command line. Based on the information and what I found in the internet I added org.codehaus.mojoversions-maven-plugin and org.apache.maven.plugins:maven-enforcer-plugin plus I tried with and without explicit version tags, since I got warnings as the versions are already defined in spring-boot-dependencies-2.5.4.pom.pom. So, when I run mvn versions:display-plugin-updates I find the outcome very confusing, since in the very end it states "BUILD SUCCESS" but if I scroll up, there is an Error message saying: "Project does not define required minimum version of Maven. Update the pom.xml to contain maven-enforcer-plugin to force the maven version which is needed to build this project". But this is what I did?!
Please see below the current parent pom. Please let me know should you need more information. Thank you in advance for your help.
Please have in mind that my expertise in Maven is rather limited. I understand the basics, when it gets to all these plugins, I get lost. Therefore, I would be grateful for "dummies" style answers.
<?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 http://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.5.4</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.agiletunes</groupId>
<artifactId>agiletunes-parent</artifactId>
<version>0.0.1</version>
<packaging>pom</packaging>
<name>agiletunes-parent</name>
<description>Maven parent for all agileTunes modules</description>
<modules>
<module>../agiletunes-productmanager</module>
<module>../agiletunes-testmanager</module>
<module>../agiletunes-shared</module>
<module>../agiletunes-authserver</module>
<module>../agiletunes-util</module>
</modules>
<properties>
<java.version>11</java.version>
<maven.compiler.release>11</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- for testing Spring Boot applications with JUnit -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>11</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.5</version>
<configuration>
<generateBackupPoms>false</generateBackupPoms>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.0</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
This is happening because what you defined in the configurations of the maven-enforcer-plugin actually maven-enforcer-plugin runs in the validation life cycle and when you run the mvn versions:display-plugin-updates with the below configurations what happen is,
<requireMavenVersion>
<version>3.0.0</version>
</requireMavenVersion>
it will check the project maven version and then check the plugin versions, and you will get an error if the project minimum version is not compatible with the plugin versions.
[INFO] Project inherits minimum Maven version as: 3.0.0
[INFO] Plugins require minimum Maven version of: 3.1.1
[INFO] Note: the super-pom from Maven 3.6.3 defines some of the plugin
[INFO] versions and may be influencing the plugins required minimum Maven
[INFO] version.
[INFO]
[ERROR] Project requires an incorrect minimum version of Maven.
[ERROR] Update the pom.xml to contain maven-enforcer-plugin to
[ERROR] force the Maven version which is needed to build this project.
[ERROR] See https://maven.apache.org/enforcer/enforcer-rules/requireMavenVersion.html
[ERROR] Using the minimum version of Maven: 3.0.0
so what you can do is change the version in the maven-enforcer-plugin to the project version.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>enforce-maven</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.1.1</version>
</requireMavenVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
and after that, the error will be gone,
[INFO] Project inherits minimum Maven version as: 3.1.1
[INFO] Plugins require minimum Maven version of: 3.1.1
[INFO] Note: the super-pom from Maven 3.6.3 defines some of the plugin
[INFO] versions and may be influencing the plugins required minimum Maven
[INFO] version.
[INFO]
[INFO] No plugins require a newer version of Maven than specified by the pom.
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
but actually you don't need maven-enforcer-plugin to define, I'm not sure if there is a list of plugins that don't need to be explicitly added, but I assume it's the most common ones like maven-surefire-plugin and maven-clean-plugin
My Maven is failing with the following error:
[ERROR] Failed to execute goal on project sdcf4j-twitch: Could not resolve dependencies for project com.github.twitch4j:sdcf4j-twitch:jar:1.0.9: Failed to collect dependencies at com.github.twitch4j:twitch4j:jar:v0.10.2 -> org.projectlombok:lombok:jar:+: Failed to read artifact descriptor for org.projectlombok:lombok:jar:+: Could not transfer artifact org.projectlombok:lombok:pom:+ from/to jitpack.io (https://jitpack.io): Transfer failed for https://jitpack.io/org/projectlombok/lombok/+/lombok-+.pom 400 Bad Request -> [Help 1]
I already tried completely wiping Intellij IDEA's files, and re-adding the dependencies, which didn't help with the error, but some wrong dependencies, that my IDE displayed.
Of course I already tried without any lombok plugin, (lombok) annotation paths and a mvn clear, but that didn't help either.
The Maven code for that project is the following:
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>de.btobastian.sdcf4j</groupId>
<artifactId>sdcf4j</artifactId>
<version>1.0.9</version>
</parent>
<groupId>com.github.twitch4j</groupId>
<artifactId>sdcf4j-twitch</artifactId>
<version>1.0.9</version>
<repositories>
<repository>
<id>jcenter</id>
<url>https://jcenter.bintray.com/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
</path>
</annotationProcessorPaths>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- Include source -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.0.4</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- Include JavaDocs -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.2</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<stylesheet>java</stylesheet>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- The core module -->
<dependency>
<groupId>de.btobastian.sdcf4j</groupId>
<artifactId>sdcf4j-core</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.twitch4j</groupId>
<artifactId>twitch4j</artifactId>
<version>v0.10.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
The Parent Pom does not differ from the original at https://github.com/Bastian/sdcf4j/blob/8f569ee5dc36be09c6595c12833d109b7127c23e/pom.xml.
If one sets up the folders correctly, you can add sdcf4j-twitch as a module in sdcf4j, just like sdcf4j-core,sdcf4j-discord4j in L17
Complete Build log:
[INFO] Scanning for projects...
[INFO]
[INFO] -----------------< com.github.twitch4j:sdcf4j-twitch >------------------
[INFO] Building sdcf4j-twitch 1.0.9
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from jitpack.io: https://jitpack.io/org/projectlombok/lombok/+/lombok-+.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.968 s
[INFO] Finished at: 2020-12-10T22:55:31+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project sdcf4j-twitch: Could not resolve dependencies for project com.github.twitch4j:sdcf4j-twitch:jar:1.0.9: Failed to collect dependencies at com.github.twitch4j:twitch4j:jar:v0.10.2 -> org.projectlombok:lombok:jar:+: Failed to read artifact descriptor for org.projectlombok:lombok:jar:+: Could not transfer artifact org.projectlombok:lombok:pom:+ from/to jitpack.io (https://jitpack.io): Transfer failed for https://jitpack.io/org/projectlombok/lombok/+/lombok-+.pom 400 Bad Request -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
I have a maven project project A that has a dependency on a different maven project project B. I publish Project B as two jars, one with the regular class files and one for its tests (I need to re-use some componenents). Maven has a plug-in for this.
The pom.xml for project A looks like this:
<properties>
<project-B.version>abcd123</project-B.version>
</properties>
<dependencies>
<dependency>
<groupId>group-id-project-B</groupId>
<artifactId>project-B</artifactId>
<version>${project-B.version}</version>
</dependency>
<dependency>
<groupId>group-id-project-B</groupId>
<artifactId>project-B</artifactId>
<classifier>tests</classifier>
<type>test-jar</type>
<version>${project-B.version}</version> <!-- Doesn't work! -->
<scope>test</scope>
</dependency>
</dependencies>
Somehow, both my IDE (IntelliJ) and mvn CLI are unable to compile this and both give an unresolved reference in my test classes (where I re-use test files from project B).
If, however, I replace ${project-B.version} with abcd123 in the test-jar dependency everything loads fine. I can't make any sense of this as to why mvn doesn't like me to use a variable in properties? This behaviour is consistent between my IDE and mvn cli.
For what it's worth, this is the output for project B when I use mvn dependency:list
group-id-project-B:project-B:test-jar:tests:abcd123:test
group-id-project-B:project-B:jar:tests:abcd123:compile
And the rest of my pom:
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
is there a bug in maven or am I missing something?
Edit:
I use mvn clean install and the truncated output is:
[INFO] --- kotlin-maven-plugin:1.3.72:test-compile (test-compile) # optimization-engine-service ---
[ERROR] MyClass.kt: (16, 19) Unresolved reference: functionName
[ERROR] MyClass.kt: (19, 28) Unresolved reference: SOME_FIELD
... etc.
Maven cannot resolve artifact that were installed/deployed with a version from parameter.
In order for your artifacts to be resolvable after build, you will have to use flatten-maven-plugin so you get an effective pom which will be resolvable by maven.
You can see an example on how to do this in maven-ci-friendly
I'm getting this error all of a sudden in maven and i'm not sure why:
Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources (default-resources) on project
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:2.7:resources (default-resources) on project
I searched in intellij for 2.7 as well as maven-resources-plugin and we aren't using those. Why is maven suddenly complaining about this when I don't even use that plugin?
There seems to be a problem with the maven-filtering dependency.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-filtering</artifactId>
<version>1.3</version>
</dependency>
</dependencies>
</plugin>
I had .der files in my src/main/resources which now when removed it builds successfully.
I am having a Maven project that has following file structure :
src/main/java/com/TestFolder/{Java file name}
This Java file contains a main method that I need to execute with argument from command line. How this can be done ? Please help.
Currently am doing something like this :
mvn exec:java -Dexec.mainClass=src.main.java.com.TestFolder.MyMainJavaClass -Dexec.args="1"
Is this right syntax to do it ? Because when i run this i get following error :
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven- plugin:1.4.0:java (default-cli) on project Staples_7Lakh: Execution default-cli of goal org.codehaus.mojo:exec-maven-plugin:1.4.0:java failed: Plugin org.codehaus.mojo:exec-maven-plugin:1.4.0 or one of its dependencies could not be resolved: The following artifacts could not be resolved: backport-util-concurrent:backport-util-concurrent:jar:3.1, org.apache.maven:maven-core:jar:2.2.1, org.codehaus.plexus:plexus-utils:jar:3.0.20: Could not transfer artifact backport-util-concurrent:backport-util-concurrent:jar:3.1 from/to central (https://repo.maven.apache.org/maven2): GET request of: backport-util-concurrent/backport-util-concurrent/3.1/backport-util-concurrent-3.1.jar from central failed: SSL peer shut down incorrectly -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginResolutionException
This problem is because the dependancies are missing in the executable jar. The executable jar needs all run time dependencies to be present. I also had a similar problem which I solved using maven assembly plugin please find below configuration with the pom file for the assembly plugin configuration -
<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>xyz.jeetendra.hibernate.Sample</groupId>
<artifactId>Excercise1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Excercise1</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>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.1.0.Final</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.6</version>
</dependency>
</dependencies>
<build>
<finalName>UserService</finalName>
<plugins>
<!-- maven Assenmbly Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<!--get all project dependency -->
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<!-- Main class in mainfest make a executable jar -->
<archive>
<manifest>
<mainClass>xyz.jeetendra.hibernate.sample.Service</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id> <!-- this is used for inheritance merges -->
<phase>package</phase> <!-- bind to the packaging phase -->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
BR