How we can use custom settings for sonar in eclipse? - eclipse

I am using SonarLint for better code. This is using default settings. I have an xml file with following entries.
<profile>
<name>Sonar Way with Custom rules</name>
<language>java</language>
<rules>
<rule>
<repositoryKey>common-java</repositoryKey>
<key>DuplicatedBlocks</key>
<priority>MINOR</priority>
</rule>
<rule>
<repositoryKey>common-java</repositoryKey>
<key>InsufficientBranchCoverage</key>
<priority>MAJOR</priority>
<parameters>
<parameter>
<key>minimumBranchCoverageRatio</key>
<value>65.0</value>
</parameter>
</parameters>
</rule>
<profile>
My question is how I can use this xml as my custom settings for SonarLint.
Thanks

The correct way of doing it is to define a Quality Profile in a SonarQube server with the rules that you want to activate and connect SonarLint to it.
For more information, check the "Connected mode" section for the IDE you are using in http://www.sonarlint.org.

Related

How to differentiate between build configurations in Eclipse (C) project template to setup build cfg sepcific settings?

I'm trying to play with Eclipse (C) project template. I found this very descriptive answer of how to work with Eclipse project template from #Jonah Graham and went through Eclipse documentation - How to add project templates to CDT
I'm able to create the project template and setup some settings by "SetMBSStringOptionValue"
<!-- Set TMP setting by adding textual build settings -->
<process
type="org.eclipse.cdt.managedbuilder.core.SetMBSStringOptionValue">
<simple name="projectName" value="$(projectName)" />
<complex-array name="resourcePaths">
<element>
<simple name="id" value=".*compiler\.option\.misc\.other*" />
<simple name="value" value="TMP_SETTING_RELEASE" />
<simple name="path" value="" />
</element>
</complex-array>
</process>
My question is how do I differentiate between build configurations? E.g. I want to setup different settings for "Debug" and "Release" build configuration. How should I do that?
AFAIK no one has provided a "process runner" that allows the configuration to be specified when setting the options.
What you can do is add your own subclass of org.eclipse.cdt.core.templateengine.process.ProcessRunner, basing it on org.eclipse.cdt.managedbuilder.core.SetMBSStringOptionValue that additionally lets you specify the configuration to apply it to. The Eclipse extension point you need is org.eclipse.cdt.core.templateProcessTypes.
Keep in mind when you do that users do a new project wizard they can choose to have/not have Debug/Release configs as shown in this screenshot:

visual studio code and private nuget

I have a library that comes from a private nuget feed. I have the url and credentials for that but dont know how to connect to the feed properly with visual studio code. I am using dotnetcore framework.
I created a Nuget.Config file in the root of my console application with the feed url and username and password but this didn't seem to pick up the packages from that feed when imputting them in the project.json. Even doing a restore would produce errors.
Does anyone have an example of how they would set up a project to do this? I know it is not normal to have the Nuget.Config file in the project but this is a test project so would not live there once the project got past proof of concept.
My nuget.config looked like this
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="CustomRepo" value="https://nuget.feed/nuget/" />
</packageSources>
<!-- Used to store credentials -->
<packageSourceCredentials>
<CustomRepo>
<add key="Username" value="something" />
<add key="ClearTextPassword" value="thepassword" />
</CustomRepo>
</packageSourceCredentials>
<!-- Used to disable package sources -->
<disabledPackageSources />
</configuration>
Apoligies this is now resolved and working with the nuget.config file in the root folder. I dont know what I did. Only thing I did was re-type the whole xml but dont know what what would have done. Anyway it is working which is great.

How to edit XML parameter using Ant

I'm trying to write a timestamp as a context parameter into my context.xml at that time I execute my Ant script.
I was trying the following:
my context.xml
<Parameter name="deployingTimeStamp"
value="16.07.2012" <!-- shall be changed! -->
override="true" />
my build.xml
<tstamp>
<format property="time" pattern="dd.MM.yyyy"
unit="hour"/>
</tstamp>
<replace file="${conf.dir}/dev/context.xml" >
<replacefilter token="deployingTimeStamp" value="${time}" />
</replace>
Unfortunately it doesn't replace the value, it just replaces the name "deployingTimeStamp" itself and changes it to the current date.
How can I solve this problem?
The replacefilter token is going to replace the token you define. Why don't you add a placeholder value in the XML (i.e. [[buildTimeStamp]] ) and then use:
<replace file="${conf.dir}/dev/context.xml" >
<replacefilter token="[[buildTimeStamp]]" value="${time}" />
</replace>
So your original xml would be
<Parameter name="deployingTimeStamp"
value="[[buildTimeStamp]]" <!-- shall be changed! -->
override="true" />
Additional tips based on comment discussion:
What you might not be doing is copying your main source files into a build directory to perform your replaces first. This is pretty standard in build scripts which is why I mentioned you check your files out of source control first. If you are not using source control and have a folder on your computer then you need to copy the files from that folder to another folder first before performing your replace and other packaging of the app.
<copy todir="../dest/dir">
<fileset dir="src_dir" excludes="**/*.java"/>
</copy>
Something like above where you copy source to working directory. THEN you perform your actions on it, and afterwards remove it when you have a package (i.e. jar file or war file or something if java). You can view the delete functionality in Ant's documentation as well:
http://ant.apache.org/manual/Tasks/copy.html

intelliJ idea 10 community edition and GWT plugin

Having hard time installing GWT plugin. Tried to search for GWT plugins and all I was able to find was GWT Imagebundle which is pretty outdated. Tried File Menu -> configure plugins but didn't help as the plugin is not installed yet.
Is there a support for GWT plugin in intelliJ 10 community edition? If there is can some one please point me to the right document to install it? Just to make sure, I installed scala plugin and I am able to see it in "Add modules" section.
This is my first time using intellij and I love it so far.
There is no GWT support in the Community Edition.
Starting from the version 11 it's not possible to add PROJECT_FOLDER/src as it was described in the previously posted (by ctorx) link http://java.dzone.com/tips/gwt-development-intellij-idea. Once we add a source folder it appears as an "Empty library" and doesn't work. This is because IDEA treats it as a folder where should be compiled classes not sources.
But there is a workaround. To fix it we have to hack the module's IML file. Find the following lines in the IML file of your entry point module
<orderEntry type="module-library">
<library>
<CLASSES />
<JAVADOC />
<SOURCES>
<root url="file://$MODULE_DIR$/src/main/java" />
</SOURCES>
</library>
</orderEntry>
and move your path into the CLASSES tag, so the entire thing looks like the following
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="file://$MODULE_DIR$/src/main/java" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>

Change GWT application behavior between deployed and debug environment

I would like to have my GWT application use different constants when debugging or developing vs when deployed. What is the right way to do this? My web searches turn up a lot of pages about debugging GWT applications, which isn't what I'm looking for.
This looks like a job for deferred binding! ;)
It would look something like this (put this in your module XML file, I haven't actually tested it, but you should get the gist of it):
<define-property name="debug" values="true,false" />
<set-property name="debug" value="true" />
<replace-with class="package.Constants">
<when-type-is class="package.Constants"/>
</replace-with>
<replace-with class="package.ConstantsDebug">
<when-type-is class="package.Constants" />
<when-property-is name="debug" value="true"/>
</replace-with>
See the docs for more information on available parameters, rules and whatnot.