I want to ignore a specific folder (named generated-sources) from my checkstyle reports, because they are generated.
I'm using eclipse-cs for displaying my violations.
i added a suppressionfilter to my xml:
<module name="SuppressionFilter">
<property name="file" value=".\suppressions.xml"/>
</module>
my suppressions.xml looks like this:
<?xml version="1.0"?>
<!DOCTYPE suppressions PUBLIC
"-//Puppy Crawl//DTD Suppressions 1.1//EN"
"http://www.puppycrawl.com/dtds/suppressions_1_1.dtd">
<suppressions>
<suppress files="\*generated-sources\*\*\.\*" checks="[a-zA-Z0-9]*"/>
</suppressions>
but it is not working. any ideas?
<suppress files="[\\/]generated-sources[\\/]" checks="[a-zA-Z0-9]*"/>
this works :)
Additionally to the answer from Philipp, I had to use an absolute pathname ( :-( ) for the suppression file:
<module name="SuppressionFilter">
<property name="file" value="/Users/xxx/workspace/suppressions.xml"/>
</module>
Looks like the Checkstyle plugin is not using the project home directory.
(at least under eclipse luna / Mac OS X)
As pointed by Thomas Welsch in his answer, there appears to be a problem with using relative pathname for the suppression xml file.
For gradle builds, This gist suggests a workaround:
in build.gradle:
checkstyle {
// use one common config file for all subprojects
configFile = project(':').file('config/checkstyle/checkstyle.xml')
configProperties = [ "suppressionFile" : project(':').file('config/checkstyle/suppressions.xml')]
}
in checkstyle.xml:
<module name="SuppressionFilter">
<property name="file" value="${suppressionFile}" default="suppressions.xml"/>
</module>
(the default value allows IDE plugins, that do not have the gradle variable sorted out, to work correctly)
This answer tries to fill in missing details in the previous answers.
Suppose I have the following maven project, which only lists the directories inside the project.
.
├── pom.xml
└── src
├── main
│ ├── java
│ │ └── edu
│ │ └── utexas
│ │ └── cs
│ │ ├── liveoak
│ │ │ ├── common
│ │ │ ├── tree
│ │ │ └── zero
│ │ ├── logging
│ │ └── sam
│ │ ├── core
│ │ │ └── instructions
│ │ ├── io
│ │ ├── ui
│ │ │ └── components
│ │ └── utils
│ └── resources
│ ├── sam-checks.xml
│ └── sam-suppressions.xml
└── test
sam-checks.xml is the checkstyle configuration file and sam-suppressions.xml is the suppression xml document. Inside sam-checks.xml, I have
<module name="SuppressionFilter">
<property name="file" value="src/main/resources/sam-suppressions.xml"/>
<property name="optional" value="false"/>
</module>
Note the location of sam-suppressions.xml is relative to the pom.xml of the project.
I want to suppress the checks for all the java files under sam directory (main/java/edu/utexas/cs/sam). To do so, my sam-suppressions.xml looks like below
<!DOCTYPE suppressions PUBLIC
"-//Checkstyle//DTD SuppressionFilter Configuration 1.2//EN"
"https://checkstyle.org/dtds/suppressions_1_2.dtd">
<suppressions>
<suppress checks="[a-zA-Z0-9]*"
files="[\\/]sam[\\/]"/>
</suppressions>
I verify my setup with mvn checkstyle:check. Everything should work.
For me using SuppressionFilter didn't worked at all. But this works, exactly for the purpose of excluding folder from scanning
<module name="BeforeExecutionExclusionFileFilter">
<property name="fileNamePattern" value=".*[\\/]folder-name-here[\\/].*$"/>
</module>
Needs to be inserted inside <module name="Checker"> section.
Docs https://checkstyle.sourceforge.io/config_filefilters.html
Related
I'm using the recommended GWT Maven Plugin and the GWT Eclipse Plugin. Actually I'm using the maven plugin with the appengine-mave-plugin to try to emulate the old Google Eclipse Plugin Super Dev Mode. Following the Google App Engine instructions from the GWT Plugin documentation and the suggested sample project gwt-basic-rpc-appengine I created this project structured that my project runs in super dev mode when I launch the App Engine local server from Eclipse (using the Eclipse Google Cloud Tools local App Engine server launcher tool). From Maven, this process works following: mvn clean package appengine:devserver_start and mvn gwt:codeserver.
However, the Maven GWT plugin only compiles one of the four modules. This is my pom.xml configuration:
<!-- GWT Maven Plugin-->
<plugin>
<groupId>net.ltgt.gwt.maven</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<version>1.0-rc-8</version>
<executions>
<execution>
<goals>
<goal>compile</goal>
<!-- <goal>test</goal>-->
</goals>
</execution>
</executions>
<configuration>
<moduleName>com.company.Administracion</moduleName>
<moduleName>com.company.Cronometro</moduleName>
<moduleName>com.company.Extension</moduleName>
<moduleName>com.company.Company</moduleName>
<!-- <moduleShortName>Nubbius</moduleShortName> -->
<failOnError>true</failOnError>
<!-- GWT compiler 2.8 requires 1.8, hence define sourceLevel here if you use
a different source language for java compilation -->
<sourceLevel>1.8</sourceLevel>
<!-- Compiler configuration -->
<localWorkers>4</localWorkers>
<draftCompile>true</draftCompile>
<compilerArgs>
<!-- Ask GWT to create the Story of Your Compile (SOYC) (gwt:compile) -->
<arg>-compileReport</arg>
<arg>-XcompilerMetrics</arg>
</compilerArgs>
<!-- DevMode configuration -->
<!-- <warDir>${project.build.directory}/${project.build.finalName}</warDir>
-->
<launcherDir>${project.build.directory}/${project.build.finalName}</launcherDir>
<classpathScope>compile+runtime</classpathScope>
<codeServerPort>auto</codeServerPort>
<!-- URL(s) that should be opened by DevMode (gwt:devmode). -->
<startupUrls>
<startupUrl>Company.jsp</startupUrl>
</startupUrls>
<jvmArgs>
<arg>-Xms1024M</arg>
<arg>-Xmx2014M</arg>
<!-- <arg>-javaagent:/home/.m2/repository/.../appengine-java-sdk-1.9.59/lib/agent/appengine-agent.jar </arg>--> <arg>-javaagent:/home/desarrollo26/Descargas/appengine-java-sdk-1.9.59/lib/agent/appengine-agent.jar </arg>
</jvmArgs>
</configuration>
</plugin>
The src folder contains the structure:
src/
├── main
│ ├── appengine
│ ├── java
│ │ └── com
│ │ └── company
│ │ ├── client
│ │ ├── server
│ │ └── shared
| |
│ ├── resources
│ │ └── META-INF
│ └── webapp
└── WEB-INF
│ ├── classes
│ │ ├── com
│ │ │ └── company
│ │ └── shared
│ │ ├── main
│ │ │ ├── java
│ │ │ └── resources
│ │ └── META-INF
│ └── lib
│ └── lib
├── META-INF
└── test
└── java
(All modules.gwt.xml files are at the same level of client/ server/ and shared/ folders.(
From Eclipse, I can create a launcher to compile my project with all the params that I have specified in my POM file but I can't automatically execute the war explode and copy process (this is the main reason for build the project from Maven).
Can I solve that compilation process with my project structure?
Con I use the GWT Eclipse project and Maven together?
Thanks!
You need to use one execution per module to compile.
That being said, you really should split your project into (at least) 5 Maven submodules (one for the server-side code, and on per GWT module, and possibly additional ones for shared code; and you could use the gwt-app and gwt-lib packagings for the GWT modules to simplify your POM files)
I'm using Eclipse Mars, and I have a Maven application using build-helper-maven-plugin, that is not covered by m2e by default, so I need to add a connector. The point is, I can add the connector when importing the maven project:
However, I have no idea how I would do this manually, when the project is already in the workspace. The pom have an error, Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:build-helper-maven-plugin:1.10:add-source, but I can't find the option install m2e connector or something like that.
The P2 Update site is here:
https://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-buildhelper/0.15.0/N/0.15.0.201207090124/
This answer helped me to discover how Eclipse knows it.
There is a Catalog that can be opened from the preferences:
You can follow the link manually: http://download.eclipse.org/technology/m2e/discovery/directory-1.8.xml
If you download the org.eclipse.m2e.discovery.oss-catalog-1.6.jar referenced as entry and you unzip it, the you will find a plugin.xml file:
org.eclipse.m2e.discovery.oss-catalog-1.6
├── META-INF
│ └── MANIFEST.MF
├── images
│ ├── extras-48.png
│ └── scm-32.png
├── lifecycle
│ ├── com.coderplus.m2e.jaxws.feature.group.pluginxml
│ ├── com.coderplus.m2e.jaxws.feature.group.xml
│ ├── ..
│ ├── org.eclipse.m2e.discovery.lifecycles.tycho.pluginxml
│ ├── org.eclipse.m2e.discovery.lifecycles.tycho.xml
│ ├── org.maven.ide.eclipse.ajdt.pluginxml
│ └── org.maven.ide.eclipse.ajdt.xml
└── plugin.xml
And this file contains the information with the P2 Update site:
<connectorDescriptor siteUrl="http://repo1.maven.org/maven2/.m2e/connectors/m2eclipse-buildhelper/0.15.0/N/0.15.0.201207090124/" id="org.eclipse.m2e.discovery.lifecyclemapping.buildhelper" groupId="lifecycles" description="buildhelper" categoryId="org.eclipse.m2e.discovery.category.lifecycles" name="buildhelper" provider="Takari, Inc." license="EPL" kind="lifecycles">
<iu id="org.sonatype.m2e.buildhelper.feature.feature.group" />
<overview summary="buildhelper" />
</connectorDescriptor>
I was asking on #arquillian Freenode IRC channel about question
Arquillian JPA tutorial: Could not create new instance of class org.jboss.arquillian.test.impl.EventTestRunnerAdaptor
when a user told me that he successfully runned
https://github.com/arquillian/arquillian-examples/tree/master/arquillian-persistence-tutorial
so I did
git clone https://github.com/arquillian/arquillian-examples.git
then in Eclipse, I clicked File->Import->Existing Maven Projects and selecte the subdirectory
arquillian-examples/arquillian-persistence-tutorial
Once Eclipse finished importing the project, I obtain in file
/src/test/java/org/arquillian/example/GamePersistenceTest.java
line 146, the error message
Game_ cannot be resolved to a variable
What can I do? In my attempt at the link at beginning of the page, this did not happpen.
I did not change any file downloaded from git repo.
Folder tree
.
├── pom.xml
├── src
│ ├── main
│ │ ├── java
│ │ │ └── org
│ │ │ └── arquillian
│ │ │ └── example
│ │ │ └── Game.java
│ │ └── resources
│ │ └── META-INF
│ │ └── persistence.xml
│ └── test
│ ├── java
│ │ └── org
│ │ └── arquillian
│ │ └── example
│ │ └── GamePersistenceTest.java
│ ├── resources
│ │ ├── arquillian.launch
│ │ ├── arquillian.xml
│ │ └── jbossas-ds.xml
│ ├── resources-glassfish-embedded
│ │ ├── glassfish-resources.xml
│ │ ├── logging.properties
│ │ └── test-persistence.xml
│ ├── resources-glassfish-remote
│ │ └── test-persistence.xml
│ └── resources-jbossas-managed
│ └── test-persistence.xml
└── target
├── classes
│ ├── META-INF
│ │ ├── MANIFEST.MF
│ │ ├── maven
│ │ │ └── org.arquillian.example
│ │ │ └── arquillian-persistence-tutorial
│ │ │ ├── pom.properties
│ │ │ └── pom.xml
│ │ └── persistence.xml
│ └── org
│ └── arquillian
│ └── example
│ └── Game.class
└── test-classes
├── arquillian.launch
├── arquillian.xml
├── glassfish-resources.xml
├── jbossas-ds.xml
├── logging.properties
├── org
│ └── arquillian
│ └── example
│ └── GamePersistenceTest.class
└── test-persistence.xml
30 directories, 24 files
The _Game class in that example is generated by the Hibernate JPA 2 metamodel generator (hibernate-jpamodelgen) that is defined as a dependency in the project POM. You'll now need to generate the metamodel by employing one the options outlined in the metamodel generator reference guide.
You could use Eclipse itself by configuring the annotation processing phase. Or you could modify the POM to use the maven-compiler-plugin configuration specified in the guide, to run as part of your build.
I'm creating a new Spring MVC webapp.
I used STS 3.0 Dashboard -> Spring Template Project -> Spring MVC Project (URL:http://dist.springsource.com/release/STS/help/org.springframework.templates.mvc-3.1.2.zip) to create the project. It created a directory structure like this:
build/
classes/
src/
main/
java/
com/
example/
web/
HomeController.java
resources/
META-INF/
log4j.xml
webapp/
resources/
WEB-INF/
classes/
spring/
appServlet/
servlet-context.xml
root-context.xml
views/
home.jsp
web.xml
test/ ***(I'll leave out what's under test)***
target/
classes/ ***(I'll leave out what's under classes)***
test-classes/ ***(I'll leave out what's under testclasses)***
WebContent/
META-INF/
MANIFEST.MF
WEB-INF/
lib/
This does not match any directory layout I can find documentation for and it certainly looks wrong. Like why is there a WebContent/WEB-INF as well as a src/webapp/WEB-INF? Why both a build/ and a target/ ?
I want to be able to build and deploy automatically from Eclipse Juno as well as from the command line using Maven, so question 1 is: how do I clean up this directory structure?
Question 2: what is the difference between src/main/resources/ and src/main/webapp/resources? How do I choose which directory to put a given static resource in?
Question 3: If I have libraries that I need to include that I cannot have Maven get, where do I put them?
I tied it in my local and following is the folder structure:
.
├── pom.xml
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ └── test
│ │ │ └── spring
│ │ │ └── HomeController.java
│ │ ├── resources
│ │ │ ├── log4j.xml
│ │ │ └── META-INF
│ │ └── webapp
│ │ ├── resources
│ │ └── WEB-INF
│ │ ├── classes
│ │ ├── spring
│ │ │ ├── appServlet
│ │ │ │ └── servlet-context.xml
│ │ │ └── root-context.xml
│ │ ├── views
│ │ │ └── home.jsp
│ │ └── web.xml
│ └── test
│ ├── java
│ │ └── com
│ │ └── test
│ │ └── spring
│ └── resources
│ └── log4j.xml
└── target
├── classes
│ ├── com
│ │ └── test
│ │ └── spring
│ │ └── HomeController.class
│ └── log4j.xml
├── m2e-wtp
│ └── web-resources
│ └── META-INF
│ ├── MANIFEST.MF
│ └── maven
│ └── com.exigen
│ └── spring
│ ├── pom.properties
│ └── pom.xml
└── test-classes
├── com
│ └── test
│ └── spring
└── log4j.xml
(I removed the .XXX files/folder which just the metadata for eclipse)
Basically, for you question:
Typical src/webapp/WEB-INF is the maven way and WebContent/WEB-INF is the WTP way. And the maven way is suggested.
Also build/ is generate by eclipse and target/ is the maven way, you can just ignore this.
for Question2, src/mian/resources is the maven way which will be compiled to the target/classes folder. and 'src/main/webapp/resources' is used for some static resources.
for Question3, actually all the 3rd-party libraries are house in the WEB-INF/lib after package, so you can put your libraries into this folder, no matter using maven or not.
Where is the lib folder with the JAR's? Is there some magic to load the JAR's from another directory?
Specifically, where is beansbinding-1.2.1.jar and the other jar is swing-layout-1.0.4.jar?
image
directory structure:
thufir#dur:~/NetBeansProjects$
thufir#dur:~/NetBeansProjects$
thufir#dur:~/NetBeansProjects$ tree fud/
fud/
├── build.xml
├── manifest.mf
├── nbproject
│ ├── build-impl.xml
│ ├── genfiles.properties
│ ├── private
│ │ ├── private.properties
│ │ └── private.xml
│ ├── project.properties
│ └── project.xml
└── src
└── dur
└── bounceme
└── net
└── view
├── NewJFrame.form
└── NewJFrame.java
7 directories, 10 files
thufir#dur:~/NetBeansProjects$
thufir#dur:~/NetBeansProjects$ head fud/build.xml
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="fud" default="default" basedir=".">
thufir#dur:~/NetBeansProjects$
you have an option of add Jar/Folder just below Add Library . Use that
Just for reference, I got the following structure:
thufir#dur:~/NetBeansProjects$
thufir#dur:~/NetBeansProjects$ tree fud/
fud/
├── build.xml
├── lib
│ ├── beans-binding
│ │ ├── beansbinding-1.2.1-doc.zip
│ │ └── beansbinding-1.2.1.jar
│ ├── CopyLibs
│ │ └── org-netbeans-modules-java-j2seproject-copylibstask.jar
│ ├── nblibraries.properties
│ └── swing-layout
│ ├── swing-layout-1.0.4-doc.zip
│ ├── swing-layout-1.0.4.jar
│ └── swing-layout-1.0.4-src.zip
├── manifest.mf
├── nbproject
│ ├── build-impl.xml
│ ├── genfiles.properties
│ ├── private
│ │ ├── config.properties
│ │ ├── private.properties
│ │ └── private.xml
│ ├── project.properties
│ └── project.xml
└── src
└── dur
└── bounceme
└── net
└── view
├── NewJFrame.form
└── NewJFrame.java
11 directories, 18 files
thufir#dur:~/NetBeansProjects$
by clicking on the project properties as so:
but don't understand where this JAR's were before.