We are using PMD to assess the quality of our "main" source code. We have our own customized ruleset that includes some category rulesets and excludes some specific rules.
Simplified example, file called pmd.xml:
<?xml version="1.0"?>
<ruleset name="Main rules"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>Main rules</description>
<rule ref="category/java/bestpractices.xml">
<exclude name="GuardLogStatement"/>
</rule>
<rule ref="category/java/security.xml"/>
</ruleset>
Analysis is launched from gradle, it works fine for our "main" source code.
Now we would like to get another more lenient ruleset for our "test" source code. As we don't want to duplicate our set of rules, what we would like to do is import this main ruleset, and exclude some more rules.
So we basically would like to keep the GuardLogStatement excluded, and also exclude rule UnusedPrivateMethod, with a file looking like this one.
<?xml version="1.0"?>
<ruleset name="Test rules"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>Test rules</description>
<!-- Test rules are based on rules for main -->
<rule ref="./config/pmd.xml">
<exclude name="UnusedPrivateMethod"/>
</rule>
</ruleset>
This doesn't work:
GuardLogStatement is excluded, but
UnusedPrivateMethod still runs.
I don't see any reference in the documentation on how to exclude a rule from a ruleset.
Anyone managed to do something similar?
It turns out this actually works fine.
Pure PEBKAC, the problem was due to my work environment.
I am keeping the question as it demonstrates a nifty way of having a ruleset for the test code derived from the ruleset for the main code.
Related
I have an update site in which I'm including my features, like this:
<?xml version="1.0" encoding="UTF-8"?>
<site>
<feature url="features/my_feature1_1.0.0.qualifier.jar" id="my_feature1" version="1.0.0.qualifier">
<category name="My Category"/>
</feature>
<feature url="features/my_feature2_1.0.0.qualifier.jar" id="my_feature2" version="1.0.0.qualifier">
<category name="My Category"/>
</feature>
...
</site>
Some of the plugins included by those features have dependencies on plugins that I download from other updates sites, right now I have to manually install those update sites before installing mine, to automate this, I can download and include those dependencies to my site.xml but at the end the .zip will contain them and the size will be too big, is there a way to link an external update site to mine so it is automatically downloaded during the installation of my update site?
It seems that there is a associateSitesURL tag that provides this behavior for site.xml. That being said, it looks like site.xml has been replaced in favor of category.xml (see for instance this answer on SO) and I don't know whether this tag is still supported.
Vogella has a section about how to create one. Using a category.xml file, you can specify an additional update site by adding a repository-reference tag. For instance, add the following code to the category.xml file to reference an Orbit update site:
<repository-reference location="https://download.eclipse.org/tools/orbit/downloads/drops/R20170818183741/repository" enabled="true" />
The URL can also be specified directly from the category.xml file editor:
I failed to find any documentation on this but I used it in a side project and it seemed to work as expected.
This is possible using an element like this <repository-reference location="http://download.eclipse.org/releases/2020-12" enabled="true" /> in category.xml. See the article Eclipse p2 site references for details.
We're running Adobe CQ, Version 5.5.0.20120220 Service Pack 2, and I've been tasked with creating some new templates and restricting the components available to those templates without having to manually configure them in design mode. I've followed the advice of the top-voted answer from Restrict the components in AEM 5.6.1. We already had this .content.xml file under our design node, so I simply copied an existing section from the file that is working fine and modified to match my new template.
The problem I'm having is that when I create a new page with the new template, the sidekick is empty. I can see in CRXDE that my configuration is live on the server. I can also see the configured components as checked when I go into design mode. But the sidekick remains empty. If I uncheck a component and re-check it, stuff will start showing up in the sidekick. I've done this and exported the design node via package manager, and the resulting file matches exactly (except whitespace) what I'm deploying from source control. Is there some gotcha that I'm missing here? Our other templates that are configured this way show the specified components in the sidekick just fine, so I'm guessing the difference lies in my template or the resourceType specified by my template, but I just can't seem to figure it out. Thanks in advance.
Edit -- Added snippet from .content.xml. The whole file is a bit long. If it's helpful, I can link to the full file instead.
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Page">
<clientlibs/>
<jcr:content
cq:doctype="html_5"
cq:lastModified="{Date}2013-05-08T14:25:15.588-04:00"
cq:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
jcr:title="My Site"
sling:resourceType="wcm/core/components/designer">
<department-resources-main jcr:primaryType="nt:unstructured">
<par
jcr:primaryType="nt:unstructured"
sling:resourceType="foundation/components/parsys"
components="[/apps/aau-42/components/components/lms-user-media]">
</par>
</department-resources-main>
</jcr:content>
<images/>
</jcr:root>
Template data, located at /apps/aau-42/templates/department-resources-main:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:description="Template for AAU Main Department Resources Pages"
jcr:primaryType="cq:Template"
allowedParents="[/apps/aau-42/templates/department]"
jcr:title="AAU Main Department Resources Page">
<jcr:content
cq:allowedTemplates="[/apps/aau-42/templates/department_resources_detail]"
jcr:primaryType="cq:PageContent"
sling:resourceType="aau-42/components/pages/department-resources-main" />
</jcr:root>
Page component data, located at /apps/aau-42/components/pages/department-resources-main:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:description="Main Department Resources Page"
jcr:primaryType="cq:Component"
jcr:title="Main Department Resources Page"
sling:resourceSuperType="aau-42/components/pages/base"/>
For anyone seeing this in the future, see the comment from #anotherdave. Cached stuff has bitten me before; I should have known. As a general rule, if something you think should be working is not working in CQ, ALWAYS clear cache or try in a fresh browser!
I'm trying to have autocompletion for liquibase.
My project works fine with liquibase, but completion doesn't work.
I'm pretty sure it did work last week, after downloading javadoc/sources from liquibase.
Now, whenever I try to have eclipse autocomplete a changelog xml, I can see this:
Loading reference grammars (sleeping).
It then disappears, and autocompletion doesn't work.
Here is an example changeset header:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">
<!-- This changelog is used to validate that liquibase works -->
<changeSet id="1" author="majoros" >
</changeSet>
</databaseChangeLog>
EDIT: could very well be a proxy issue. I was briefly fully connected to the internet (don't ask...), and it's working now. Still, my coworkers should have it working, too (and I'd like to understand).
Eclipse should be able to use autocomplete on XML files that have a descriptor (or whatever it's called).
Liquibase's wiki has some examples for database change sets. These all include references to xsd files. These provide information on the structure of the XML.
Sample XML for 1.9:
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
</databaseChangeLog>
Sample XML for 2.0:
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
</databaseChangeLog>
Eclipse fetches the xsd files from the web so an Internet connection is required. If you're behind a proxy you have to configure Eclipse to use a proxy. This might explain why it didn't work at first.
To configure a proxy in Eclipse:
Window > Preferences > General > Network connections
I'm working on a GWT project in Eclipse and for some reason the .nocache.js file is no longer being built, but a .devmode.js is. I cannot find any setting that would control this. Could anyone point me in the right direction?
Edit: My gwt.xml is below
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='myapp'>
<inherits name='com.google.gwt.user.User' />
<inherits name='com.google.gwt.gadgets.Gadgets' />
<inherits name='org.adamtacy.GWTEffects' />
<inherits name='com.google.gwt.user.theme.clean.Clean' />
<entry-point class='myapp.Entry' />
</module>
Update
This appears to be related to the use of gwt-gadgets. Inheriting the library and the use of a class that extends Gadget as an entry point causes things to be built only with devmode.js and not nocache.js.
Has anyone therefore developed any Google Gadgets using GWT and deployed them successfully?
Update 2
Turns out this is not an issue, although it seems a bit odd. If Gadgets are deployed using the generated gadget.xml, then this references devmode.js and so things work as expected. The naming is off-putting though.
I want to deploy my ASP.NET MVC site and have the following script.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\MyProjName\MyProjName.csproj"/>
<PropertyGroup>
<NewInstallDir>C:\DeployFolder\</NewInstallDir>
<BinDir>$(NewInstallDir)bin\</BinDir>
</PropertyGroup>
<Target Name="Build">
<MSBuild Projects="..\MySlnName.sln"
Properties="Configuration=Release;Platform=Any CPU;OutputPath=$(BinDir)" />
<Copy SourceFiles="#(Content->'..\MyProjName\%(RelativeDir)%(FileName)%(Extension)')"
DestinationFiles="#(Content->'$(NewInstallDir)%(RelativeDir)%(FileName)%(Extension)')" />
<Copy SourceFiles="#(None->'..\MyProjName\%(RelativeDir)%(FileName)%(Extension)')"
DestinationFiles="#(None->'$(NewInstallDir)%(RelativeDir)%(FileName)%(Extension)')" />
<MakeDir Directories="#(Folder->'$(NewInstallDir)%(RelativeDir)')" />
</Target>
</Project>
Main idea.
I copied binary to C:\DeployFolder (take structure of folder from sources). I build my dll to C:\DeployFolder\Bin (I don't have this folder in sources folder so I need separately copy this).
I run my script - all works instead of copy DLLs to OutputPath. Same scripts works for other asp.net mvc project. I have no idea what is wrong in this case.
I complete this issue with workaround but I would like to know what is wrong with this script.
The first thing I'd try is to replace your use of the deprecated $(OutputPath) with $(OutDir). From when I've seen this error, 9 times out of 10 it is due to a mismatch between the Platform/Configuration requested and how a particular project is actually defined. Take care to keep track of the discrepency between "Any CPU" (with a space) preferred by solution files and "AnyCPU" actually used inside project files for $(Platform). Some project wizards only set up an "x86" Platform or otherwise omit "AnyCPU" which can cause the OutputPath to be empty.
Beyond that, the approach of importing a project file and then building a solution (presumbably that includes the very same project" is a bit off center. Consider making the deployment changes you desire within the project file itself, through an import. You can either wire into the existing build targets at the right place, or perhaps add an additional target.