I've create a vaadin application with maven using the following comand:
mvn archetype:generate -DarchetypeGroupId=com.vaadin
-DarchetypeArtifactId=vaadin-archetype-application -DarchetypeVersion=7.7.12-DgroupId=com.example -DartifactId=myapplication -Dversion=0.1 -Dpackaging=war
It has created a right project; Now I'm going to create a custom widget, follow the instruction on
https://vaadin.com/docs/v7/framework/gwt/gwt-eclipse
The wizard new-->other--> Vaadin 8 widget creates the necessary file:
But when I try to compile I get:
[ERROR] Failed to execute goal
org.apache.maven.plugins:maven-compiler-plugin:3.1:compile
(default-compile) on project myapplication: Compilation failure:
Compilation failure: [ERROR]
/C:/Users/fmi/eclipse-workspace/myapplication/src/main/java/com/example/client/mycomponent/MyComponentWidget.java:[3,37]
package com.google.gwt.user.client.ui does not exist [ERROR]
/C:/Users/fmi/eclipse-workspace/myapplication/src/main/java/com/example/client/mycomponent/MyComponentWidget.java:[6,40]
cannot find symbol [ERROR] symbol: class Label
I know that may be I have to add dependency in the pom, but I'm asking why the wizard has this bug?
Note in the picture I see Vaadin 8 widget, while the project has been created with archetype 7.7
Is a bug in the wizard or a mistake by me?
thanks
I've resolved adding:
<dependency>
<groupId>com.vaadin</groupId>
<artifactId>vaadin-client</artifactId>
</dependency>
It is necessary to compile widgets; It is still unclear why in the documentation has not reported.
Related
I have two Maven projects A and B, where project B is nested in project A. The structure looks like the following:
Project A:
src/test/java:
DependencyClass.java
Project B:
src/test/java:
MyTest.java
pom.xml
pom.xml
I'm trying to import DependencyClass.java (project A) into MyTest.java (project B), and be able to invoke the methods in DependencyClass.java from MyTest.java. But when I tried to package project B, it failed at the compile phase:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project : Compilation failure:
[ERROR] MyTest.java:[7,41] package XXX does not exist
[ERROR] MyTest.java:[17,9] cannot find symbol
[ERROR] symbol: class DependencyClass.java
I have found some answers such as this and this, and I have done the following:
added the maven-jar-plugin with a goal of "test-jar" in the pom.xml of project A
added the dependency to project A in project B's pom.xml, and declared type as "test-jar" and scope as "test".
Eclipse is able to resolve DependencyClass.java without giving errors, but it just failed when I tried to build with Maven. Any suggestion or idea on what I might be missing? Thanks in advance
Edit: I have also tried adding another dependency in project B's pom.xml, with the following scope and type:
<scope>compile</scope>
<type>jar</type>
But I got more errors when building project B - now it even starts to complain about jUnit and other built-in classes.
I have resolved my error. The fix was to remove the <scope> tag. So now in project B's pom.xml, I declared two dependencies of project A, one with <type>jar</type> and another with <type>test-jar</type>, and both don't have <scope> declared.
In project A's pom.xml, the execution goal of the "maven-jar-plugin" should specify both "jar" and "test-jar".
I run the command below with GitLab CI / CD:
mvn -s /etc/gitlab-runner/maven/settings-maven.xml --batch-mode test sonar:sonar
-Dsonar.java.source=1.8
-Dsonar.host.url=${SONARHOST}
-Dsonar.projectKey=${SONARKEY}
-Dsonar.projectName=${SONARNAME}
-Dsonar.projectVersion=${SONARVERSION}
-Dsonar.sources=myproject_core/src/main/java,myproject_service/src/main/java,myproject_persistance/src/main/java
-Dsonar.language=java
-Dsonar.java.binaries=myproject_core/target/classes,myproject_service/target/classes,myproject_persistance/target/classes
-Dsonar.java.libraries=**/*.jar
-Dsonar.java.coveragePlugin=jacoco
-Dsonar.surefire.reportPaths=myproject_core/target/surefire-reports,myproject_service/target/surefire-reports,myproject_persistance/target/surefire-reports
-Dsonar.junit.reportPaths=myproject_core/target/surefire-reports,myproject_persistance/target/surefire-reports,myproject_service/target/surefire-reports
-Dsonar.verbose=true
-Dsonar.binaries=myproject_core/target/classes,myproject_service/target/classes,myproject_persistance/target/classes
-Dsonar.jacoco.reportPaths=myproject_core/target/jacoco.exec,myproject_service/target/jacoco.exec,myproject_persistance/target/jacoco.exec
-Dsonar.exclusions=**/*Test*/**
-Dsonar.tests=myproject_core/src/test,myproject_service/src/test,myproject_persistance/src/test
So, I want to analyse 3 project core, service and persistance (I have 7 modules in my project)
myproject-parent
myproject-core
myproject-persistance
myproject-service
myproject- ...
But, I have this error :
[ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project myproject-parent: The directory '/builds/git-myproject/myproject-parent/**myproject_persistance/myproject_core**/src/main/java' does not exist for Maven module fr.xxx.xxx.myproject:myproject_persistance:jar:1.1. Please check the property sonar.sources -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar (default-cli) on project myproject-parent: The directory '/builds/git-myproject/myproject-parent/myproject_persistance/myproject_core/src/main/java' does not exist for Maven module fr.xxx.xxx.myproject:myproject_persistance:jar:1.1. Please check the property sonar.sources
On this sonarqube error, i can see that in the path, module persistance is include on module core, but this is not the case
I'm looking for why but I can't find. Have you ever had this problem ?
There is a parameter projectVersionPolicyId in many mojos of Maven Release Plugin, e.g. http://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#projectVersionPolicyId. However, it seems that they provided no examples of how I can use it.
When I try:
$ mvn --batch-mode release:prepare -DprojectVersionPolicyId=foo
It shows an error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.0-M1:prepare (default-cli) on project maven-release-test: Policy 'foo' is unknown, available: [default] -> [Help 1]
It looks like that there only 1 available policy (which is default). Is there any way to add more possible policies?
You can use SemVerVersionPolicy as well
I am trying to build a RCP product in Jenkins with configuration: maven: 3.0.5 and Java 1.7. It is building locally but failing with the following error in Jenkins.
Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
[INFO] [1m------------------------------------------------------------------------[m
[INFO] [1;31mBUILD FAILURE[m
[INFO] [1m------------------------------------------------------------------------[m
[INFO] Total time: 7.360 s
[INFO] Finished at: 2019-10-24T13:55:12-05:00
[INFO] [1m------------------------------------------------------------------------[m
Waiting for Jenkins to finish collecting data
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project myrcp-app: Compilation failure: Compilation failure:
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/java/com/company/myrcp/app/internal/handlers/AboutHandler.java:[8,23] package org.eclipse.swt does not exist
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/java/com/company/myrcp/app/internal/handlers/AboutHandler.java:[9,30] package org.eclipse.swt.events does not exist
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/java/com/company/myrcp/app/internal/handlers/AboutHandler.java:[10,30] package org.eclipse.swt.events does not exist
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/java/com/company/myrcp/app/internal/handlers/AboutHandler.java:[11,32] package org.eclipse.swt.graphics does not exist
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/java/com/company/myrcp/app/internal/handlers/AboutHandler.java:[12,30] package org.eclipse.swt.layout does not exist
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/java/com/company/myrcp/app/internal/handlers/AboutHandler.java:[13,30] package org.eclipse.swt.layout does not exist
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/com/company/myrcp/app/internal/handlers/AboutHandler.java:[14,30] package org.eclipse.swt.layout does not exist
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/java/com/company/myrcp/app/internal/handlers/AboutHandler.java:[15,31] package org.eclipse.swt.widgets does not exist
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/java/com/company/myrcp/app/internal/handlers/AboutHandler.java:[16,31] package org.eclipse.swt.widgets does not exist
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/java/com/company/myrcp/app/internal/handlers/AboutHandler.java:[17,31] package org.eclipse.swt.widgets does not exist
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/java/com/company/myrcp/app/internal/handlers/AboutHandler.java:[18,31] package org.eclipse.swt.widgets does not exist
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/java/com/company/myrcp/app/internal/handlers/AboutHandler.java:[19,31] package org.eclipse.swt.widgets does not exist
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/java/com/company/myrcp/app/internal/handlers/AboutHandler.java:[20,31] package org.eclipse.swt.widgets does not exist
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/java/com/company/myrcp/app/internal/handlers/AboutHandler.java:[45,39] cannot find symbol
[ERROR] symbol: class Dialog
[ERROR] location: class com.company.myrcp.app.internal.handlers.AboutHandler
[ERROR] /c:/jenkins/workspace/myrcp-app/src/main/java/com/company/myrcp/app/nternal/handlers/AboutHandler.java:[47,34] cannot find symbol
[ERROR] symbol: class Shell
[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]
The following dependency is also present in POM:
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt</artifactId>
<scope>compile</scope>
</dependency>
Not sure if I have to add any plugins to make it run in Jenkins?
If you are using maven you specify the version. Once you successfully built-in local version you can investigate is all the dependency is available. If you try to run in eclipse internally eclipse understand the dependency and help your build in local.
Fortunately, if you are running Jenkins in another machine to build the code from repo you have to specify the version and maven downloads the dependency and get it build.
It can be eliminated by maintaining the remote repository internally. If you have an internal repo then consider checking the repo availability.
I am developing a simple Java 8 project with Maven and a custom AnnotationProcessor.
If I use only the Dagger 2.15 or my AnnotationProcessor, it works well, but If I use both of them, maven build will fails with the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project MyProject: Fatal error compiling: java.lang.NoClassDefFoundError: com/google/common/util/concurrent/FluentFuture: com.google.common.util.concurrent.FluentFuture -> [Help 1]
I tried to import com.google.common.util.concurrent.FluentFuture class from com.google.guava.guava repository (version r05, 19.0, 24.1-jre), but it has not worked.
Project structure:
There is a Maven project, what contains the annotations, and two AnnotationProcessors (one of them validates only, the other generates source code) (Based on this article)
There is another Maven project, what uses this project as a dependency. In that I would like to use Dagger 2 for dependency injection (I imported it just like it is in the description in Dagger 2 page).
What can I do?
Thank you for your help!
I downgraded to dagger 2.14.1 and stopped getting that error.