Issue with maven compile - java

When trying to build in jenkins an E2E project using selenium wd and testng , I got the following error:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[9,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[10,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[11,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[12,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[13,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[14,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[15,22] package org.testng.xml does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[21,42] cannot find symbol
symbol: class IReporter
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[24,37] cannot find symbol
symbol: class XmlSuite
location: class resources.ExtentReporterNG
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[24,63] cannot find symbol
symbol: class ISuite
location: class resources.ExtentReporterNG
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[43,33] cannot find symbol
symbol: class IResultMap
location: class resources.ExtentReporterNG
[INFO] 11 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.605 s
[INFO] Finished at: 2020-04-03T19:51:37-03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project E2EProject: Compilation failure: Compilation failure:
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[9,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[10,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[11,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[12,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[13,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[14,18] package org.testng does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[15,22] package org.testng.xml does not exist
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[21,42] cannot find symbol
[ERROR] symbol: class IReporter
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[24,37] cannot find symbol
[ERROR] symbol: class XmlSuite
[ERROR] location: class resources.ExtentReporterNG
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[24,63] cannot find symbol
[ERROR] symbol: class ISuite
[ERROR] location: class resources.ExtentReporterNG
[ERROR] /Users/VickoS/.jenkins/E2EProject/src/main/java/resources/ExtentReporterNG.java:[43,33] cannot find symbol
[ERROR] symbol: class IResultMap
[ERROR] location: class resources.ExtentReporterNG
[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
This was not happening when running the mvn compile command before, but after updating my POM and re-compiling, it started to show in the terminal too. The project works perfectly fine when running it from the testng.xml in eclipse.
Here's how my POM file looks like
<url>http://maven.apache.org</url>
<build>
<resources>
<resource>
<directory>src/main/java/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.apple</groupId>
<artifactId>AppleJavaExtensions</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.6</version>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.8.2</version>
</dependency>
</dependencies>
</project>
Attaching image of how the project looks like:
Project

I was finally able to solve this by updating my POM file doing the following:
Removing the extent report dependency that had the avenstack groupID
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.0.6</version>
</dependency>
updating the other Extent Report to this v:
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>3.1.5</version>
</dependency>
And adding this one too:
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.28</version>
</dependency>

Related

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project grpc_hello_server: Compilation failure

I'm trying to create a gRPC service with Java using below codelab.
I created a sample proto file. While compiling the .proto using maven, i got a build failure error. It says javax.annotation.Generated anottation class is not found.
Could you help me find the root cause of the issue and steps to fix it. I feel it should be a versioning issue but not clear on how to solve it.
https://codelabs.developers.google.com/codelabs/cloud-grpc-java/index.html?index=..%2F..index#2
Errors:
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/grpc_hello_server/target/generated-sources/protobuf/grpc-java/com/example/grpc/GreetingServiceGrpc.java:[20,18] cannot find symbol
symbol: class Generated
location: package javax.annotation
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.845 s
[INFO] Finished at: 2020-06-29T16:56:21-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project grpc_hello_server: Compilation failure
[ERROR] /home/grpc_hello_server/target/generated-sources/protobuf/grpc-java/com/example/grpc/GreetingServiceGrpc.java:[20,18] cannot find symbol
[ERROR] symbol: class Generated
[ERROR] location: package javax.annotation
[ERROR]
[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] 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.
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.example.grpc</groupId>
<artifactId>grpc_hello_server</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>grpc_hello_server</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-netty</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-protobuf</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>io.grpc</groupId>
<artifactId>grpc-stub</artifactId>
<version>1.7.0</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
</properties>
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.6.2</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.0</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:3.4.0:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:1.7.0:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Issue is due to missing dependency in pom.xml for Java 9+
<dependency> <!-- necessary for Java 9+ -->
<groupId>org.apache.tomcat</groupId>
<artifactId>annotations-api</artifactId>
<version>6.0.53</version>
<scope>provided</scope>
</dependency>
Any reason you are using Java 1.6?
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
Can you change it to 1.7 and see if it works?

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1

i am facing issue while compiling my maven project through command prompt , need help
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project Automation: Compilation failure: Compilation failure:
i am using JDK14 and latest eclipse IDE Version: 2020-03 (4.15.0)
Error message :
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/kits/sit/Base_Setup/BQUK_Agent_Flow.java:[50,39] unmappable character (0x93) for encoding UTF-8
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/kits/sit/Base_Setup/BQUK_Agent_Flow.java:[50,66] unmappable character (0x94) for encoding UTF-8
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[3,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[11,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[12,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[13,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[14,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[15,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[16,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[17,22] package org.testng.xml does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[23,48] cannot find symbol
[ERROR] symbol: class IReporter
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[31,37] cannot find symbol
[ERROR] symbol: class XmlSuite
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[31,63] cannot find symbol
[ERROR] symbol: class ISuite
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[52,33] cannot find symbol
[ERROR] symbol: class IResultMap
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/RetryAnalyzer.java:[4,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/RetryAnalyzer.java:[5,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/RetryAnalyzer.java:[6,39] cannot find symbol
[ERROR] symbol: class IRetryAnalyzer
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/RetryAnalyzer.java:[25,30] cannot find symbol
[ERROR] symbol: class ITestResult
[ERROR] location: class com.qa.analyzer.RetryAnalyzer
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/MyTransformer.java:[6,18] package org.testng does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/MyTransformer.java:[7,30] package org.testng.annotations does not exist
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/MyTransformer.java:[11,39] cannot find symbol
[ERROR] symbol: class IAnnotationTransformer
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/analyzer/MyTransformer.java:[13,31] cannot find symbol
[ERROR] symbol: class ITestAnnotation
[ERROR] location: class com.qa.analyzer.MyTransformer
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[36,26] cannot find symbol
[ERROR] symbol: class ISuite
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[37,49] cannot find symbol
[ERROR] symbol: class ISuiteResult
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[39,42] cannot find symbol
[ERROR] symbol: class ISuiteResult
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[40,53] cannot find symbol
[ERROR] symbol: class ITestContext
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] /C:/work/Automation Learning/Automation-testing-practise/src/main/java/com/qa/ExtentReportListener/AutomationExtentReport.java:[56,42] cannot find symbol
[ERROR] symbol: class ITestResult
[ERROR] location: class com.qa.ExtentReportListener.AutomationExtentReport
[ERROR] -> [Help 1]
POM.xml that i am using :
<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.kingfisher</groupId>
<artifactId>Automation</artifactId>
<packaging>jar</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Maven Quick Start Archetype</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>testng.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.14.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.17</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.8</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>
</dependencies>
</project>
First of all remove the unwanted testng dependency from the POM.xml and second you have added the scope as test in the testng dependency. You have also accessed the class file of the testng dependency with the scope test in src/main/java. Please remove the test scope from the dependency and then execute the test again. Let me know if the issue persists even after fixing the above issues.

mvn install error: package does not exist

I have this scenarion:
I have a maven project with spring boot where i just have some tipical pojo classes inside this package structure like: com.demo.core
pom structure
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<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>
com/demo/core/Person.java
Then im trying to use that base project as a dependency of other spring boot project which is responsible of database persistence.
here i use spring data, lombok and others.
Second project pom dependencies:
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- local dependencies -->
**
<dependency>
<groupId>com.demo</groupId>
<artifactId>core-baseproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
**
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
I run mvn clean install in base project and verify that the jar file is in my local .m2 repository structure.
when i try to run mvn clean install in the second project i got an error saying that the package com.demo.core does not exits therefore did not find classes inside that package.
Error details:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------< com.demo:jpa-dataprovider-simple >---------------
[INFO] Building jpa-dataprovider-simple 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) # jpa-dataprovider-simple ---
[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) # jpa-dataprovider-simple ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /home/demo/sts-eclipse-wrkspace-simple-pos/jpa-dataprovider-simple-pos/src/main/java/com/demo/jpa/dataprovider/mapper/TerminalConfigJpaMapper.java:[4,35] package com.demo.core.entity does not exist
[ERROR] /home/demo/sts-eclipse-wrkspace-simple-pos/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/mapper/TerminalConfigJpaMapper.java:[8,59] cannot find symbol
symbol: class TerminalConfig
location: class com.demo.jpa.dataprovider.mapper.TerminalConfigJpaMapper
[ERROR] /home/demo/sts-eclipse-wrkspace-simple-pos/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/mapper/TerminalConfigJpaMapper.java:[18,23] cannot find symbol
symbol: class TerminalConfig
location: class com.demo.jpa.dataprovider.mapper.TerminalConfigJpaMapper
[ERROR] /home/demo/sts-eclipse-wrkspace-simple-pos/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[9,35] package com.demo.core.entity does not exist
[ERROR] /home/demo/sts-eclipse-wrkspace-simple-pos/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[10,36] package com.demo.core.gateway does not exist
[ERROR] /home/demo/sts-eclipse-wrkspace-simple-pos/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[14,54] cannot find symbol
symbol: class TerminalConfigGateway
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[24,36] cannot find symbol
symbol: class TerminalConfig
location: class com.demo.jpa.dataprovider.gateway.JpaTerminalConfigGatewayImpl
[ERROR] /home/demo/sts-eclipse-wrkspace-simple-pos/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[24,16] cannot find symbol
symbol: class TerminalConfig
location: class com.demo.jpa.dataprovider.gateway.JpaTerminalConfigGatewayImpl
[INFO] 8 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.714 s
[INFO] Finished at: 2020-01-14T18:08:20-05:00
[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 jpa-dataprovider-simple: Compilation failure: Compilation failure:
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/d/jpa/dataprovider/mapper/TerminalConfigJpaMapper.java:[4,35] package com.demo.core.entity does not exist
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/mapper/TerminalConfigJpaMapper.java:[8,59] cannot find symbol
[ERROR] symbol: class TerminalConfig
[ERROR] location: class com.demo.jpa.dataprovider.mapper.TerminalConfigJpaMapper
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/mapper/TerminalConfigJpaMapper.java:[18,23] cannot find symbol
[ERROR] symbol: class TerminalConfig
[ERROR] location: class com.demo.jpa.dataprovider.mapper.TerminalConfigJpaMapper
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[9,35] package com.demo.core.entity does not exist
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[10,36] package com.demo.core.gateway does not exist
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[14,54] cannot find symbol
[ERROR] symbol: class TerminalConfigGateway
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[24,36] cannot find symbol
[ERROR] symbol: class TerminalConfig
[ERROR] location: class com.demo.jpa.dataprovider.gateway.JpaTerminalConfigGatewayImpl
[ERROR] /home/demo/sts-eclipse-wrkspace-simple/jpa-dataprovider-simple/src/main/java/com/demo/jpa/dataprovider/gateway/JpaTerminalConfigGatewayImpl.java:[24,16] cannot find symbol
[ERROR] symbol: class TerminalConfig
[ERROR] location: class com.demo.jpa.dataprovider.gateway.JpaTerminalConfigGatewayImpl
[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
Have any one a clue how to solve this???
Im using:
Spring Tool Suite 4
Version: 4.5.0.RELEASE
java-8-openjdk-amd64
maven 3.6.0
springboot version 2.1.11
Thanks in advance.
There is something new to me, when i review inside jar file the structure is like this:
Jar structure generated by spring boot
For some reason i changed the maven config in eclipse to use the installed and not the embedbeb one, but now i get this error.
[ERROR] Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 1.619 s <<< FAILURE! - in com.oxypora.jpa.dataprovider.JpaDataproviderSimplePosApplicationTests
[ERROR] contextLoads(com.oxypora.jpa.dataprovider.JpaDataproviderSimplePosApplicationTests) Time elapsed: 0.015 s <<< ERROR!
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to parse configuration class [com.oxypora.jpa.dataprovider.JpaDataproviderSimplePosApplication]; nested exception is java.io.FileNotFoundException: class path resource [com/oxypora/pos/core/gateway/TerminalConfigGateway.class] cannot be opened because it does not exist
Caused by: java.io.FileNotFoundException: class path resource [com/oxypora/pos/core/gateway/TerminalConfigGateway.class] cannot be opened because it does not exist
I found another solution when you have two or more springboot projects and you want to wire them one as dependency of others.
The solution is not to use spring-boot-maven-plugin, this plugin override the normal package of the jar causing your classes and package structure to move under BOOT-INF/classes.
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
I solved the problem, springboot project generated a diferent jar structure configured in the metainf file, so that classes are not pleced in the tipical folders.
what i did was to change the core project to a simple maven project with out spring boot complexity, and now the second project (springboot one) compiled without problems.
There was not nescessary to have the base project as a springboot one.

maven can't find dependency basiclti-util

I need to implement LTI Consumer in my E-learning platform
I'm trying to run this code LTI example Java
here is the pom.xml file
<?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>
<groupId>net.paulgray</groupId>
<artifactId>ExampleLtiApp</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>MockLtiApp</name>
<properties>
<endorsed.dir>${project.build.directory}/endorsed</endorsed.dir>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<springVersion>4.0.6.RELEASE</springVersion>
</properties>
<dependencies>
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-web-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-messaging</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-websocket</artifactId>
<version>${springVersion}</version>
</dependency>
<dependency>
<groupId>org.imsglobal</groupId>
<artifactId>basiclti-util</artifactId>
<version>1.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArguments>
<endorseddirs>${endorsed.dir}</endorseddirs>
</compilerArguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<outputDirectory>${endorsed.dir}</outputDirectory>
<silent>true</silent>
<artifactItems>
<artifactItem>
<groupId>javax</groupId>
<artifactId>javaee-endorsed-api</artifactId>
<version>7.0</version>
<type>jar</type>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
but maven doesn't contain basic-util-1.0.1-SNAPSHOT
so I edit it to
<dependency>
<groupId>org.imsglobal</groupId>
<artifactId>basiclti-util</artifactId>
<version>1.1.1</version>
</dependency>
but it gave me this error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project ExampleLtiApp: Compilation failure: Compilation failure:
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[29,30] package org.imsglobal.basiclti does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[30,30] package org.imsglobal.basiclti does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[74,5] cannot find symbol
[ERROR] symbol: class LtiSigner
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[78,56] cannot find symbol
[ERROR] symbol: class LtiVerificationResult
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[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
how can I solve this problem?
Edit:
I tried basiclti-util-1.0.0 but it gave this error
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project ExampleLtiApp: Compilation failure: Compilation failure:
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/JsonReader.java:[5,43] package org.imsglobal.lti2.objects.consumer does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[29,30] cannot find symbol
[ERROR] symbol: class LtiSigner
[ERROR] location: package org.imsglobal.basiclti
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[31,43] package org.imsglobal.lti2.objects.consumer does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[32,43] package org.imsglobal.lti2.objects.provider does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[33,43] package org.imsglobal.lti2.objects.provider does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[34,43] package org.imsglobal.lti2.objects.provider does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[74,5] cannot find symbol
[ERROR] symbol: class LtiSigner
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[155,13] cannot find symbol
[ERROR] symbol: class ToolProfile
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[204,13] cannot find symbol
[ERROR] symbol: class SecurityContract
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[116,9] cannot find symbol
[ERROR] symbol: class ToolConsumer
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[116,70] cannot find symbol
[ERROR] symbol: class ToolConsumer
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[122,9] cannot find symbol
[ERROR] symbol: class ToolProxy
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[122,28] cannot find symbol
[ERROR] symbol: class ToolProxy
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[123,23] cannot find symbol
[ERROR] symbol: variable ToolProxy
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[156,9] cannot find symbol
[ERROR] symbol: class ToolProfile
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[156,30] cannot find symbol
[ERROR] symbol: class ToolProfile
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[188,49] package ToolConsumer does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[193,47] package ToolConsumer does not exist
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[205,9] cannot find symbol
[ERROR] symbol: class SecurityContract
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[ERROR] /home/feras/NetBeansProjects/LTIEX/lti-example-java/src/main/java/net/paulgray/exampleltiapp/LtiController.java:[205,41] cannot find symbol
[ERROR] symbol: class SecurityContract
[ERROR] location: class net.paulgray.exampleltiapp.LtiController
[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
lti-example-java was out-of-date, and using an old branch of basiclti-util-java (one where the package structure wasn't compatible with 1.0.0 or 1.0.1).
It's updated and should be working now.
Use
<dependency>
<groupId>org.imsglobal</groupId>
<artifactId>basiclti-util</artifactId>
<version>1.0.0</version>
</dependency>
version 1.0.0 contains the basiclti package.Version 1.1.1 removes the basiclti package

Android Robolectric packages not found. Unknown packaging: apk

Hi I'm trying to use the maven android plugin and robolectric to get tests working. Right now I just have one test class which is under src/test.... I've followed the instructions here to try and get this working: http://pivotal.github.com/robolectric/maven-quick-start.html
UPDATED: I have followed the advice of those who posted to me here and here is my latest Pom.xml and compile output.
Here is my Pom.xml:
<project 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>org.mozilla.android.sync</groupId>
<artifactId>android-sync</artifactId>
<version>1</version>
<packaging>apk</packaging>
<name>sync</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.5</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
<!--
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android-test</artifactId>
<version>2.3.3</version>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<!-- try 4.10 once we get this working -->
<version>4.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<sourceDirectory>src</sourceDirectory>
<!--<pluginManagement>-->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<!-- version 2.3 defaults to java 1.5, so no further configuration needed-->
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>com.jayway.maven.plugins.android.generation2</groupId>
<!--
<artifactId>maven-android-plugin</artifactId>
<version>2.8.4</version>-->
<artifactId>android-maven-plugin</artifactId>
<version>3.0.0-alpha-13</version>
<configuration>
<sdk>
<!-- platform or api level (api level 4 = platform 1.6)-->
<platform>10</platform>
</sdk>
<emulator>
<!-- the name of the avd device to use for starting the emulator -->
<avd>android-14</avd>
</emulator>
<undeployBeforeDeploy>true</undeployBeforeDeploy>
</configuration>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.6</version>
<configuration>
<excludes>
<exclude>**/Test*.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
<!--</pluginManagement>-->
</build>
</project>
Output of mvn clean install:
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building sync 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # android-sync ---
[INFO] Deleting /Users/jason/dev/work/android-sync/target
[INFO]
[INFO] --- android-maven-plugin:3.0.0-alpha-13:generate-sources (default-generate-sources) # android-sync ---
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] ANDROID-904-002: Found aidl files: Count = 0
[INFO] /Users/jason/dev/android-sdk-mac_x86/platform-tools/aapt [package, -m, -J, /Users/jason/dev/work/android-sync/target/generated-sources/r, -M, /Users/jason/dev/work/android-sync/AndroidManifest.xml, -S, /Users/jason/dev/work/android-sync/res, --auto-add-overlay, -I, /Users/jason/dev/android-sdk-mac_x86/platforms/android-10/android.jar]
[INFO]
[INFO] --- maven-resources-plugin:2.5:resources (default-resources) # android-sync ---
[debug] execute contextualize
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /Users/jason/dev/work/android-sync/src/main/resources
[INFO] skip non existing resourceDirectory /Users/jason/dev/work/android-sync/target/generated-sources/extracted-dependencies/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) # android-sync ---
[INFO] Compiling 21 source files to /Users/jason/dev/work/android-sync/target/classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[6,33] package com.xtremelabs.robolectric does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[7,16] package org.junit does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[8,23] package org.junit.runner does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[10,26] package org.hamcrest does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[10,0] static import only from classes and interfaces
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[11,23] package org.junit does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[11,0] static import only from classes and interfaces
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[13,1] cannot find symbol
symbol: class RunWith
#RunWith(RobolectricTestRunner.class)
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[16,5] cannot find symbol
symbol : class Test
location: class org.mozilla.android.sync.test.MyActivityTest
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[19,28] cannot find symbol
symbol : method equalTo(java.lang.String)
location: class org.mozilla.android.sync.test.MyActivityTest
[INFO] 10 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.019s
[INFO] Finished at: Sat Nov 12 13:02:42 PST 2011
[INFO] Final Memory: 12M/81M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project android-sync: Compilation failure: Compilation failure:
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[6,33] package com.xtremelabs.robolectric does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[7,16] package org.junit does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[8,23] package org.junit.runner does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[10,26] package org.hamcrest does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[10,0] static import only from classes and interfaces
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[11,23] package org.junit does not exist
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[11,0] static import only from classes and interfaces
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[13,1] cannot find symbol
[ERROR] symbol: class RunWith
[ERROR] #RunWith(RobolectricTestRunner.class)
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[16,5] cannot find symbol
[ERROR] symbol : class Test
[ERROR] location: class org.mozilla.android.sync.test.MyActivityTest
[ERROR] /Users/jason/dev/work/android-sync/src/test/java/org/mozilla/android/sync/test/MyActivityTest.java:[19,28] cannot find symbol
[ERROR] symbol : method equalTo(java.lang.String)
[ERROR] location: class org.mozilla.android.sync.test.MyActivityTest
[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
I think you might have that problem due to the order of the test dependency in the pom file. Move the junit one to be the last one or at least behind the robolectric one. That should fix it.
Check out the working robolectric sample app for more comparison.
I did make sure that all dependencies were listed before the android dependencies
Actually the order of dependencies does matter, in the link your provided yourself, see the important comments in the sample pom.xml:
<!-- Make sure this is below the android dependencies -->
<dependency>
<groupId>com.pivotallabs</groupId>
<artifactId>robolectric</artifactId>
<version>X.X.X</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
From my own experiences, I think this library is still in a development stage, their API is not stable and change quite a lot between different version, code working in a old version for example 0.9.4 may not working in 1.0-XX or later. try download/use the latest versrion from there sonatype repository
So I was having the same problems too. For what it's worth, I wasn't using maven or gradle, here's how I fixed this issue.
In your Test class:
Make sure the Roboelectric library is first in the list of dependencies (In IntelliJ, click on your project in the Navigation Pane and hit F4).
import org.junit.runner.RunWith; <- The RunWith annotation is actually part of JUnit.
import org.roboelectric.RoboeletricTestRunner;
I hope this helps!

Categories

Resources