What I am trying to do is to push out a couple of parent poms for all of our sub projects. I have a single project that contains a single parent pom with two child module poms. Packaging for all three are of type pom if this makes a difference. When I deploy though it is failing to deploy the child modules saying that they are skipped.
Parent Pom
<groupId>com.test.cpbx</groupId>
<artifactId>parent</artifactId>
<packaging>pom</packaging>
<version>1.1-SNAPSHOT</version>
<name>Parent Pom</name>
<scm>
<connection>scm:svn:https://url/trunk</connection>
</scm>
<modules>
<module>appia</module>
<module>rialto</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<configuration>
<goals>deploy</goals>
<providerImplementations>
<svn>javasvn</svn>
</providerImplementations>
</configuration>
<dependencies>
<dependency>
<groupId>com.google.code.maven-scm-provider-svnjava</groupId>
<artifactId>maven-scm-provider-svnjava</artifactId>
<version>2.0.5</version>
<scope>compile</scope>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>
This is one of my child poms, they are the same with the only change being the artifactId name
Child 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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.test.cpbx</groupId>
<artifactId>parent</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<artifactId>rialto-parent</artifactId>
<packaging>pom</packaging>
<name>Rialto Parent POM</name>
</project>
Output
mvn -B -DreleaseVersion=1.1 -DdevelopmentVersion=1.2.0-SNAPSHOT release:prepare -DdryRun
...
[INFO] Not removing release POMs
[INFO] Executing completion goals - since this is simulation mode it is running against the original project, not the rewritten ones
[INFO] Full run would be commit 3 files with message: '[maven-release-plugin] prepare for next development iteration'
[INFO] Release preparation simulation complete.
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Parent Pom ........................................ SUCCESS [2.573s]
[INFO] Appia Parent POM .................................. SKIPPED
[INFO] Rialto Parent POM ................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.749s
[INFO] Finished at: Wed May 21 14:52:30 CDT 2014
[INFO] Final Memory: 15M/114M
[INFO] ------------------------------------------------------------------------
There was some confusion with the output of maven.
The output does not mean it is skipping building the modules or deploying the modules.
It is a message about the refactoring of the versions. The output is telling us that the parent pom owns the version and the child versions are dependent on the parent pom. This means that it does not need to refactor the child modules pom.xml so it prints the child in the reactor summary as SKIPPED.
Another possibility is that it mean that the process did not worked until being able to build those modules:
In case of an activated parallel execution it can show something like this:
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Parent Pom ........................................ SUCCESS [2.573s]
[INFO] Child1 POM ........................................ SKIPPED
[INFO] Child2 POM ........................................ SKIPPED
[INFO] Dependent Sibling POM ............................. FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
If one of the Childx artifacts is needed by the dependent sibling, it can be requesting the dependency before this even was built. This causes the whole build to fail.
It is just misleading to think the last was only failed because the other were missed during build. An ABORTED state in the overview would have saved some time.
Related
Pom A is parent of Pom B and Pom C.
Pom A has a profile sample-profile that overwrites a property <scala.version> defined in Pom A.
The default value of <scala.version> is 2.11, the value defined in sample-profile for this property is is 2.12.
In dependencyManagement section of Pom A, one dependency's artifactId depends on the value of <scala.version>.
<dependency>
<groupId>com.github.scopt</groupId>
<artifactId>scopt_${scala.version}</artifactId>
<version>3.7.0</version>
</dependency>
Project C depends on scopt_${scala.version}. Project B depends on Project C.
Desired behavior is :
run mvn clean install -DskipTests -Psample-profileand get Project C depend on scopt_2.12.
Actual behavior is :
When I run mvn clean install -DskipTests -Psample-profile or mvn dependency:tree -Psample-profile within the directory of Project B , the artifactId of Project C is scopt_2.11 instead of scopt_2.12
mvn help:effective-pom -Psample-profile yields no trace of scopt_2.11 though.
How shall I fix this ?
[Edit] - Initially, I build everything from Pom A with sample-profile (When I do so, I have the desired behavior, i.e. having scopt_2.12 as a dependency for project C). Then after doing code modifications on project B, I only need to build from Pom B (with the same sample-profile). And this is when I have the unexpected behavior (i.e. having scopt_2.11 as a dependency for project C).
I'm not sure about the real reason but maven might try to resolve dependencies before it resolves profiles. Especially since they may affect plugin, which may extends maven (see maven extensions).
You could try this:
Declare both versions in your dependencyManagement, without any profile jinx.
In the child project (B), use <artifactId>scopt_${scala.version}</artifactId> as artifactId.
This may work.
The following works for me, using a Junit jar for convienience.
Parent pom is:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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.essexboy</groupId>
<artifactId>parent-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>parent-demo</name>
<profiles>
<profile>
<id>default</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
<profile>
<id>profile1</id>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
</dependency>
</dependencies>
</dependencyManagement>
</profile>
</profiles>
<modules>
<module>mod-b</module>
<module>mod-c</module>
</modules>
</project>
Project C looks like:
<?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>
<artifactId>parent-demo</artifactId>
<groupId>com.essexboy</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>mod-c</artifactId>
<name>mod-a</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
</dependencies>
</project>
Project B looks like:
<?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>
<artifactId>parent-demo</artifactId>
<groupId>com.essexboy</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<artifactId>mod-b</artifactId>
<name>mod-a</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.essexboy</groupId>
<artifactId>mod-c</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>
greg.clinker#lldevuk-gclinke:~/work/parent-demo/mod-b$ mvn dependency:tree
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com.essexboy:mod-b >-------------------------
[INFO] Building mod-a 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # mod-b ---
[INFO] com.essexboy:mod-b:jar:1.0-SNAPSHOT
[INFO] \- com.essexboy:mod-c:jar:1.0-SNAPSHOT:compile
[INFO] \- junit:junit:jar:4.11:compile
[INFO] \- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.774 s
[INFO] Finished at: 2021-05-27T09:47:47+01:00
[INFO] ------------------------------------------------------------------------
greg.clinker#lldevuk-gclinke:~/work/parent-demo/mod-b$ mvn dependency:tree -Pprofile1
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com.essexboy:mod-b >-------------------------
[INFO] Building mod-a 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) # mod-b ---
[INFO] com.essexboy:mod-b:jar:1.0-SNAPSHOT
[INFO] \- com.essexboy:mod-c:jar:1.0-SNAPSHOT:compile
[INFO] \- junit:junit:jar:4.13.2:compile
[INFO] \- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.620 s
[INFO] Finished at: 2021-05-27T09:47:51+01:00
[INFO] ------------------------------------------------------------------------
I am in the process of upgrading maven and some maven dependencies that used to work but im getting a RuntimeException after upgrading.
I have removed the logic from my maven plugin, so its pure apache maven code and none of my own:
import org.apache.maven.lifecycle.mapping.LifecyclePhase;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.Mojo;
#Mojo(name = "hello", requiresProject = true, defaultPhase = LifecyclePhase.PROCESS_RESOURCES)
public class HelloMojo extends AbstractMojo {
public void execute() throws MojoExecutionException {
System.out.println("Hello There!");
}
}
I currently have the following pom file which works fine:
<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>org.example</groupId>
<artifactId>hello-maven-plugin</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<!-- Changing this to 3.5.4 works -->
<version>3.6.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-plugin-plugin</artifactId>
<version>3.3</version>
<configuration>
<skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound>
</configuration>
</plugin>
</plugins>
</build>
</project>
But after doing a mvn versions:use-latest-versions it updates maven-core and everything from version 3.6.0+ is causing the following error when doing a mvn install:
[INFO] --- maven-plugin-plugin:3.3:descriptor (default-descriptor) # hello-maven-plugin ---
[WARNING] Using platform encoding (Cp1252 actually) to read mojo metadata, i.e. build is platform dependent!
[INFO] Applying mojo extractor for language: java
[INFO] Mojo extractor for language: java found 0 mojo descriptors.
[INFO] Applying mojo extractor for language: bsh
[INFO] Mojo extractor for language: bsh found 0 mojo descriptors.
[INFO] Applying mojo extractor for language: java-annotations
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.110 s
[INFO] Finished at: 2020-03-16T16:30:04-04:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-plugin-plugin:3.3:descriptor (default-descriptor) on project hello-maven-plugin: Execution default-descriptor of goal org.apache.maven.plugins:maven-plugin-plugin:3.3:descriptor failed.: RuntimeException -> [Help 1]
Is there anything else that I need to change when upgrading to maven core 3.6.3?
when i am trying to create Spring Boot Project using New Version which is "v 2.1.7"
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
this time its through Following error:
Description Resource Path Location
Type
Unknown pom.xml /demo-1 line 1 Maven Configuration Problem
If i am going to replace This new Version to my previous old version in porm.xml file with name space its Working good without any error,
and if i deleted .m2 folder and reinstall eclipse then its support to new version but i want to use existing eclipse with New version of Spring Boot, what can i do for it.
it is possible to update existing .m2 folder ?
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.1.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>demo-1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo-1</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.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-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
when i am trying to install maven this time following error show
[INFO] Scanning for projects...
[INFO]
[INFO] -------------------------< com.example:demo-1 >-------------------------
[INFO] Building demo-1 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # demo-1 ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) # demo-1 ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to D:\Enternship\SPRING BOOT\demo-1\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.933 s
[INFO] Finished at: 2019-09-02T18:45:56+05:30
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "pom.xml" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project demo-1: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR] -> [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/MojoFailureException
just configure the JDK path the steps are
right-click on the project
click on properties
type java build path and go to java build path
click on libraries
click on JRE system libraries
edit that
click on alternate JRE
click on Installed JREs
click on Add
select standard VM
click Next
place your JDK path and select that
By this, you will not see the error
=>No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
I tried to use Maven to install the dependency Unirest. I downloaded the .jar file (unirest-java-1.4.9.jar) and added it to the POM like this:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
</dependencies>
</dependencyManagement>
In addition, I added the .jar in Eclipse:
Now Maven says that the package does not exist. Eclipse did not say that anything was wrong.
What did I do wrong?
Are the warnings in the beginning a problem?
My logs:
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.sap.cloud.sdk.sensorLive:sensorLive-application:war:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. # com.sap.cloud.sdk.sensorLive:sensorLive:1.0-SNAPSHOT, C:\Users\c5283284\Documents\Projekte\Transformation module\sensorLive\pom.xml, line 52, column 21
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.sap.cloud.sdk.sensorLive:sensorLive-unit-tests:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. # com.sap.cloud.sdk.sensorLive:sensorLive:1.0-SNAPSHOT, C:\Users\c5283284\Documents\Projekte\Transformation module\sensorLive\pom.xml, line 52, column 21
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.sap.cloud.sdk.sensorLive:sensorLive-integration-tests:jar:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. # com.sap.cloud.sdk.sensorLive:sensorLive:1.0-SNAPSHOT, C:\Users\c5283284\Documents\Projekte\Transformation module\sensorLive\pom.xml, line 52, column 21
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.sap.cloud.sdk.sensorLive:sensorLive:pom:1.0-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-jar-plugin is missing. # line 52, column 21
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] sensorLive - Root [pom]
[INFO] sensorLive - Application [war]
[INFO] sensorLive - Unit Tests [jar]
[INFO] sensorLive - Integration Tests [jar]
[INFO]
[INFO] --------------< com.sap.cloud.sdk.sensorLive:sensorLive >---------------
[INFO] Building sensorLive - Root 1.0-SNAPSHOT [1/4]
[INFO] --------------------------------[ pom ]---------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (SAP S/4HANA Cloud SDK Project Structure Checks) # sensorLive ---
[INFO]
[INFO] --------< com.sap.cloud.sdk.sensorLive:sensorLive-application >---------
[INFO] Building sensorLive - Application 1.0-SNAPSHOT [2/4]
[INFO] --------------------------------[ war ]---------------------------------
[INFO]
[INFO] --- maven-enforcer-plugin:3.0.0-M2:enforce (SAP S/4HANA Cloud SDK Project Structure Checks) # sensorLive-application ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # sensorLive-application ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # sensorLive-application ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 9 source files to C:\Users\c5283284\Documents\Projekte\Transformation module\sensorLive\application\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /C:/Users/c5283284/Documents/Projekte/Transformation module/sensorLive/application/src/main/java/com/sap/cloud/sdk/sensorLive/Servlet.java:[16,1] package com.mashape.unirest.http does not exist
[ERROR] /C:/Users/c5283284/Documents/Projekte/Transformation module/sensorLive/application/src/main/java/com/sap/cloud/sdk/sensorLive/Servlet.java:[17,32] package com.mashape.unirest.http does not exist
[INFO] 2 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for sensorLive - Root 1.0-SNAPSHOT:
[INFO]
[INFO] sensorLive - Root .................................. SUCCESS [ 0.485 s]
[INFO] sensorLive - Application ........................... FAILURE [ 2.233 s]
[INFO] sensorLive - Unit Tests ............................ SKIPPED
[INFO] sensorLive - Integration Tests ..................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.079 s
[INFO] Finished at: 2019-01-31T10:22:32+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project sensorLive-application: Compilation failure: Compilation failure:
[ERROR] /C:/Users/c5283284/Documents/Projekte/Transformation module/sensorLive/application/src/main/java/com/sap/cloud/sdk/sensorLive/Servlet.java:[16,1] package com.mashape.unirest.http does not exist
[ERROR] /C:/Users/c5283284/Documents/Projekte/Transformation module/sensorLive/application/src/main/java/com/sap/cloud/sdk/sensorLive/Servlet.java:[17,32] package com.mashape.unirest.http does not exist
[ERROR] -> [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/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :sensorLive-application
My POM:
<?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>
<name>sensorLive - Root</name>
<description>sensorLive - Root</description>
<groupId>com.sap.cloud.sdk.sensorLive</groupId>
<artifactId>sensorLive</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.sap.cloud.s4hana</groupId>
<artifactId>sdk-bom</artifactId>
<version>2.9.1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
</dependencies>
</dependencyManagement>
<properties>
<java.version>1.8</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<maven.compiler.testSource>${java.version}</maven.compiler.testSource>
<maven.compiler.testTarget>${java.version}</maven.compiler.testTarget>
<project.build.resourceEncoding>UTF-8</project.build.resourceEncoding>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<modules>
<module>application</module>
<module>unit-tests</module>
<module>integration-tests</module>
</modules>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.maventest.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.openejb.maven</groupId>
<artifactId>tomee-maven-plugin</artifactId>
<version>1.7.1</version>
<configuration>
<tomeeVersion>1.7.1</tomeeVersion>
<tomeeClassifier>plus</tomeeClassifier>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>3.0.0-M2</version>
<executions>
<execution>
<id>SAP S/4HANA Cloud SDK Project Structure Checks</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<rules>
<requireMavenVersion>
<version>3.3.9</version>
</requireMavenVersion>
<requireJavaVersion>
<version>${java.version}</version>
</requireJavaVersion>
<reactorModuleConvergence />
</rules>
<fail>true</fail>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
This is how I import Unirest:
import com.mashape.unirest.http.*;
You added your dependency to the dependencyManagement section of your pom. This section is intended for multi-module projects where a dependency can be defined in the parent pom but used in child modules. Further reading.
To be able to use your dependency, you must open your child-module's pom (in this case the pom of application, unit-tests or integration-tests) and tell maven that you wish to use the dependency there like so:
<?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">
...
<groupId>com.sap.cloud.sdk.sensorLive</groupId>
<artifactId>application</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
</dependency>
</dependencies>
...
</project>
Try removing unirest-java dependency from dependencyManagement tag and add in dependencies tag like below example
Sample example:
<dependencies>
<dependency>
<groupId>com.mashape.unirest</groupId>
<artifactId>unirest-java</artifactId>
<version>1.4.9</version>
</dependency>
</dependencies>
if your using Eclipse, just do a maven update and that should do the trick.
Have Eclipse Juno, maven 2.2.1, and m2eclipse running on a Red Hat Linux platform...
Downloaded a simple example to build a Restful Hello World web service (which works on my OS X computer) but for some odd reason, its not working on my Linux box.
Here's the pom.xml:
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mkyong.common</groupId>
<artifactId>RESTfulExample</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>RESTfulExample Maven Webapp</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>maven2-repository.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.8</version>
</dependency>
</dependencies>
<build>
<finalName>RESTfulExample</finalName>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
When I try to issue an mvn compile from the command line:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building RESTfulExample Maven Webapp
[INFO] task-segment: [compile]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources {execution: default-resources}]
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).
Project ID: null:jersey-server:bundle:null
Reason: Cannot find parent: com.sun.jersey:jersey-project for project: null:jersey -server:bundle:null for project null:jersey-server:bundle:null
[INFO] ------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ------------------------------------------------------------------------
[INFO] Total time: < 1 second
[INFO] Finished at: Thu Nov 15 17:07:16 PST 2012
[INFO] Final Memory: 8M/309M
[INFO] ------------------------------------------------------------------------
Has anyone encountered this issue? I don't understand how it works on my OS X computer but not on Linux (which I don't think is the issue).
Thank you for taking the time to read this.
I would completely remove the entire repositories element in your pom.xml file. This way maven will use the standard central repository. Then change the version of jersey-server to 1.15 (the latest).
The latest jersey in that java.net repository is dated august 2011, while the standard central maven repository has version 1.15 dated October 30 2012.
I suspect that the reason it works on one machine and not the other is that in your ~/.m2/repository cache you have good cached files on one machine but not on the other. It may be necessary to delete the entire ~/.m2/repository/com/sun/jersey hierarchy and rebuild. You may have corrupted files there.