Liquibase autocompletion in eclipse (maven project) - eclipse

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

Related

PMD: How to exclude a rule imported from a ruleset

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.

AEM custom logs creation from scripts

we are automating the AEM configurations, we have a requirement for creating a custom log file. current Manual step followed is
login to AEM Felix console -> Sling -> log support ->Add new logger
parameters updated are log level, log file and logger.
is there a way to automate this log creation ? Please share your inputs.
Thanks in advance,
You can do this by configuring OSGI content nodes or by creating OSGI config files. For instance, I created an OSGI config node at this location:
/apps/cq/config.publish/org.apache.sling.commons.log.LogManager.factory.config-util.xml
That file has contents such as this:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
org.apache.sling.commons.log.file="logs/util.log"
org.apache.sling.commons.log.level="debug"
org.apache.sling.commons.log.names="[com.myorg.commons.util.MyUtil,com.myorg.commons.util.OtherUtil]"
org.apache.sling.commons.log.pattern="\{0,date,dd.MM.yyyy HH:mm:ss.SSS} *{4}* [{2}] {3} {5}"/>
Similarly, you can also do this for
/apps/cq/config.publish/org.apache.sling.commons.log.LogManager.factory.writer-util.xml
With contents such as
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="sling:OsgiConfig"
org.apache.sling.commons.log.file="logs/util.log"
org.apache.sling.commons.log.file.buffered="{Boolean}false"
org.apache.sling.commons.log.file.number="5"
org.apache.sling.commons.log.file.size="20MB"/>
See https://helpx.adobe.com/experience-manager/6-3/sites/deploying/using/configuring-osgi.html for more details on how these files can be made specific to run modes.
When you install the package containing these nodes, since they are jcr:primaryType of sling:OsgiConfig they will automatically be picked up and configured in your environment (per run mode matching).

What is dedicated .org.eclipse.wst.jsdt.core.javascriptValidator.launch file on eclipse project .externalToolBuilders folder?

I have problem to deploy my project to run on tomcat server on Eclicpse IDE after when it imported from git repository. And nowhere I can find the problem. Now I am looking into the project folder structure and found .externalToolBuilders folder with .org.eclipse.wst.jsdt.core.javascriptValidator.launch file:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="org.eclipse.wst.jsdt.core.javascriptValidator"/>
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>
I want to know what this file do and or it can has the influence for my problem?
This is a launch configuration file for an Ant Builder. It looks like this builder is disabled. Builders are listed in the 'Builders' tab on the Project Properties dialog.
It is unlikely that this is causing whatever problem you are having.

guideline to generate boilerplate for xml like applicationContext?

I know that it's possible to generate this schema above by selecting all these options in STS(Spring Tool Suite):
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
The point is I want to generate beans schema in STS(without any copy-paste as I have done it). If anyone faced with that, please guide me! Because copy-paste is senseless.
In STS: Right click on some folder or package -> New -> Spring Bean Configuration File.
It will create empty xml with defined beans schema.

How to centralize the CVS server name for an Eclipse project-set (.psf)?

We have users around the world who use the same source code. The location of the CVS repository (in the below sample: cvsserver) differs from one office to another. The project set file we have commited in CVS (for use by all users) looks like:
<?xml version="1.0" encoding="UTF-8"?>
<psf version="2.0">
<provider id="org.eclipse.team.cvs.core.cvsnature">
<project reference="1.0,:pserver:cvsserver:/topdir,Project1,Project1,BRANCH"/>
<project reference="1.0,:pserver:cvsserver:/topdir,Project2,Project2,BRANCH"/>
<project reference="1.0,:pserver:cvsserver:/topdir,Project3,Project3,BRANCH"/>
.... lots of other projects with the same "pserver:cvsserver:/topdir" part
</provider>
... several workingSets
</psf>
Users in the same office as me can checkout from this project-set as-is. But for users in other offices, the cvs server name is not cvsserver... They have to find/replace cvsserver in the .psf file and then they can checkout the projects (using Import-->Team-->Team Project Set in Eclipse).
Is it possible to use a variable or property in Eclipse so that the user will set that variable once and for all and use the .psf file without modifying it?
Or as an alternative, can one declare the CVS server name at the top of the .psf file, so that the user will have to edit just that single declaration in the file?
Thanks in advance for any help, since I can't find that specific information.
I can't see any support for anything like this in the .psf loading code (org.eclipse.team.internal.ui.ProjectSetImporter which uses org.eclipse.team.internal.ccvs.ui.CVSProjectSetSerializer for CVS).