问题
I have Eclipse Indigo 3.7 base with MyEclipse 10 Java enterprise development plug-in:
- I have installed Sonar plug-in for eclipse.
- Installed Sonar server and running it locally from localhost (localhost:9000)
- Tested the Server connection in Eclipse from
Windows>Preferences>Sonar>Servers. Connection is successful. - For my Project, ran the Maven goal for sonar (sonar:sonar). Build is successful. I am able to browse the results in localhost. (localhost:9000)
My issue is with Associating the project to Sonar. When i right click on my project, Configure > Associate with Sonar, I get a screen where nothing happens.
Basically the screen has 2 fields,Project and Sonar Project. The Project field contains the name of my Project and Sonar Project field lists this message - "click here to start searching for a remote Sonar project"
- I click on that field and enter my groupid:artifactid but nothing happens.
- I also tried entering the Project Name listed in Sonar dashboard but that also does not help.
When i right click on my project, In the context menu i am unable to see 'Sonar' option.
Help me associate my project to Sonar in eclipse. Please let me know what i am missing. Thanks in advance.
回答1:
I had the same issue with my Liferay project in Eclipse (liferay-plugins-sdk.6.2.0) and here is how I got it working:
- Install the eclipse plugin, and test server connection
- Install the Sonar server and start it (for example on
yourhost:9000) - Go to
yourhost:9000and login (admin/admin unless you changed it) - Go to Settings -> System -> Provisioning
- Create new project (
+Createin the top right corner) - I've used key=Liferay6.2 and name=liferay-plugins-sdk-6.2.0
After the above steps I went back to my eclipse project and in Configure > Associate with Sonar I was able to search/find the liferay project.
回答2:
When using Sonar Eclipse, you can associate Eclipse projects only to the corresponding Sonar modules (unless you are working on a single-module project, which is pretty rare in fact).
This means that you can't associate the root project (which is logical as by definition, a root project has no sources in Sonar). You have to right-click on all the imported Maven modules, and associate them all in a single run.
回答3:
Go to your project folder in eclipse workspace from the terminal and run following command:
mvn sonar:sonar
This command will create your sonar project. Try associating the project again. Make sure you enter the name associated with your project from your pom file. (Clear the text field)
回答4:
BEST ANSWER AFTER SO MUCH ANALYSIS(I have faced the same problem)
- Forget to add to associate with SonarQube first
- If you want to add sonar group id create
sonar-project.properties
Just add below code
# Required metadata
sonar.projectKey=javapractice
sonar.projectName=javapractice
sonar.projectVersion=1.0
# Comma-separated paths to directories with sources (required)
sonar.sources=src
# Language
sonar.language=java
# Encoding of the source files
sonar.sourceEncoding=UTF-8
- download sonnar-runner from github.
- download sonar example from github
- download sonar
- run sonar as per your operating system from command prompt
- go to sonar example path like
c:/sonar example/java/.. /.. *.propertiespath (beside src) - run sonnar-runner
c:/.... / sonnar-runner.bat -e - go to browser
http://localhost:9000after that (login:admin/admin) - your project is displayed in the browser.
回答5:
Choose Maven on the project and then choose Select Maven Profiles and then choose with-sonar in Eclipse. This will enable the Sonar functionality on projects. Now you will see the Sonar option when you right click on projects.
来源:https://stackoverflow.com/questions/16191413/associating-a-project-to-sonar-in-eclipse