I'm using Intellij's ui-designer in my Maven project and I understand from this question that I need to use ideauidesigner-maven-plugin to create a jar out of my code.
So I add this to my pom.xml:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>ideauidesigner-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>javac2</goal>
</goals>
</execution>
</executions>
<configuration>
<fork>true</fork>
<debug>true</debug>
<failOnError>true</failOnError>
</configuration>
</plugin>
And now when I'm trying to create the jar with "mvn clean package",
I'm getting the following error "Index 20838 out of bounds for length 6699".
here is the error with the call stack:
Related
Im trying learn Spring and Maven but im having some trouble.
When I go to run my tests from the terminal using mvn clean install I'm getting this error: java.lang.IllegalArgumentException: URI is not hierarchical . This is the block of code that throws the error :
LocationWeatherRootResponseTest.class.getClassLoader().getResource("extent.xml")).toURI()
When I change the above code to the following Im getting a null pointer exception.
LocationWeatherRootResponseTest.class.getClassLoader().getResourceAsStream("extent.xml")))
Update
When I change the code to the below Im getting a new error.
File file = new File(WeatherTest.class.getClassLoader().getResource("extent.xml").getPath());
Reporter.loadXMLConfig(file);
stacktrace :
java.io.FileNotFoundException: file:/home/user/IdeaProjects/spring-cucumber-test-harness/common/target/common-1.0-SNAPSHOT.jar!/extent.xml (No such file or directory)
I managed to solve this issue using maven-remote-resources-plugin . Now when I run mvn clean install on the master POM the framework runs from e2e.
In the module containing the resources I wanted to share, I added the following to the POM file
<build>
<plugins>
<plugin>
<artifactId>maven-remote-resources-plugin</artifactId>
<version>1.7.0</version>
<executions>
<execution>
<goals>
<goal>bundle</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>**/*.xml</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
In the module where I want to use the resource. I added the following
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-remote-resources-plugin</artifactId>
<version>1.7.0</version>
<configuration>
<resourceBundles>
<resourceBundle>{groupId}:{resource artifactId}:1.0-SNAPSHOT</resourceBundle>
</resourceBundles>
</configuration>
<executions>
<execution>
<goals>
<goal>process</goal>
</goals>
</execution>
</executions>
</plugin>
So I'm creating a maven plugin using the maven-plugin-plugin. The HelpMojo in maven-plugin-plugin generates a java source file.
Unfortunately, PMD is picking this up and complaining about it. Is there a way to have PMD ignore just a single source file? Thanks!
Maven PMD Configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<executions>
<execution>
<id>pmd-verify</id>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
<configuration>
<printFailingErrors>true</printFailingErrors>
</configuration>
</execution>
</executions>
</plugin>
Generated sources usually end up (with maven) in a subdirectory in target/generated-sources, for the maven-plugin-plugin it's target/generated-sources/plugin.
You can exclude these complete directories with excludeRoots, e.g.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<executions>
<execution>
<id>pmd-verify</id>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
<configuration>
<printFailingErrors>true</printFailingErrors>
<excludeRoots>
<excludeRoot>target/generated-sources/plugin</excludeRoot>
</excludeRoots>
</configuration>
</execution>
</executions>
</plugin>
There is also a file based exclude option.
I've just got the problem some hours ago and it always seemd to working until now.
I generate code in my pom on the following way:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<configuration>
<sourceDestDir>${basedir}/target/generated/java</sourceDestDir>
<keep>true</keep>
<verbose>true</verbose>
<extension>true</extension>
<wsdlDirectory>${basedir}/src/main/resources/META-INF</wsdlDirectory>
</configuration>
<executions>
<execution>
<id>ecad-ws</id>
<phase>generate-sources</phase>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>wsdl/ECadDocumentServiceWSDL.wsdl</wsdlFile>
</wsdlFiles>
<staleFile>${project.build.directory}/jaxws/stale/wsdl.ECadDocumentServiceWSDL.done</staleFile>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${basedir}/src/main/resources/META-INF/xsd</schemaDirectory>
<packageName>be.fgov.health.ecad.xmlstructure</packageName>
<outputDirectory>${basedir}/target/generated/java</outputDirectory>
</configuration>
</plugin>
and I use those generated classes in my project.
If I then do a "right click -> maven -> clean" + "right click -> maven -> install" everything is working.
But when I run mvn clean install -DskipTest=true, then maven can't find the generated sources.. I'm stuck for several hours already and can't really find it. (doing this in Eclipse btw)
EDIT:
just figured out the following: If I remove the second plugin (to generate by xsd) I won't get any error.. If I put all the code that uses thoes generated classes in comment ofc.
Another EDIT:
I've changed the outputDirectory from the jaxb generation and now it's working. Can anyone explain me why it can't be the same as the wsimport location?
By default, the jaxb2-maven-plugin deletes the outputDirectory before putting the generated classes inside.
You can control this behaviour with the attribute clearOutputDir. Your plugin configuration would then look like :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaDirectory>${basedir}/src/main/resources/META-INF/xsd</schemaDirectory>
<packageName>be.fgov.health.ecad.xmlstructure</packageName>
<outputDirectory>${basedir}/target/generated/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
I have the following configuration within my pom.xml that checks for PMD violations:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.version}</version>
<configuration>
<linkXRef>true</linkXRef>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<targetJdk>1.7</targetJdk>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
</execution>
</executions>
</plugin>
When I run a build using the command mvn clean install, the PMD checks are run as last step of the build process. Rather, I would want the PMD checks to run as the first step of the build.
Does anybody know how could I achieve this?
Add the phase element to your POM.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.version}</version>
<configuration>
<linkXRef>true</linkXRef>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<targetJdk>1.7</targetJdk>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
</execution>
</executions>
</plugin>
The validate phase is the first phase of the maven lifecycle: http://maven.apache.org/guides/introduction/introduction-to-the-lifecycle.html
Thanks for your answers #JamesB and #PetrMensik for letting me know about the phase element within the POM. It helped me solve my problem. I finally settled for this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.version}</version>
<configuration>
<linkXRef>true</linkXRef>
<sourceEncoding>UTF-8</sourceEncoding>
<minimumTokens>100</minimumTokens>
<targetJdk>1.7</targetJdk>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
</execution>
</executions>
</plugin>
I used the phase:compile, the reason being I have plenty of tests in my project which take up a lot of time to execute. And, its quite irritating to wait for those tests to finish and be notified about a PMD violation at the end of all the tests. I needed something just before the tests. Hence, I settled for compile.
Further suggestions are welcome. :)
You need to hook execution of this plugin to a different Maven lifecycle phase (validation comes as the first one in default lifecycle).
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
<goal>cpd-check</goal>
</goals>
</execution>
</executions>
See this the list of the available Maven phases for reference.
I set build configuration
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>${pmd.plugin.version}</version>
<configuration>
<failOnViolation>true</failOnViolation>
<printFailingErrors>true</printFailingErrors>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
I know this question has been asked over and over again, and its always an Eclipse Maven JIXB problem. I don't think it has ever been resolved.
When I try to test my code I get the following error
Unable to access binding information for class com.generated.xml.addbooking.Request
Make sure the binding has been compiled
java.lang.NoSuchFieldException: JiBX_bindingList
at java.lang.Class.getDeclaredField(Class.java:1882)
at org.jibx.runtime.BindingDirectory.getBindingList(BindingDirectory.java:68)
Now I have generated the POJOs and have generated a binding.xml file using the following POM.
<plugin>
<groupId>org.jibx</groupId>
<artifactId>jibx-maven-plugin</artifactId>
<version>1.2.5</version>
<executions>
<execution>
<id>schemata-a</id>
<goals>
<goal>schema-codegen</goal>
</goals>
<configuration>
<schemaLocation>src/main/resources/schemas</schemaLocation>
<includeSchemas>
<includeSchema>AddBookingRequest.xsd</includeSchema>
</includeSchemas>
<schemaBindingDirectory>src/main/java</schemaBindingDirectory>
<includeSchemaBindings>
<includeSchemaBindings>binding.xml</includeSchemaBindings>
</includeSchemaBindings>
<options>
<package>com.generated.xml.addbooking</package>
</options>
</configuration>
</execution>
<execution>
<id>schemata-b</id>
<goals>
<goal>schema-codegen</goal>
</goals>
<configuration>
<schemaLocation>src/main/resources/schemas</schemaLocation>
<includeSchemas>
<includeSchema>SearchHotelPriceRequest.xsd</includeSchema>
</includeSchemas>
<schemaBindingDirectory>src/main/java</schemaBindingDirectory>
<includeSchemaBindings>
<includeSchemaBindings>binding.xml</includeSchemaBindings>
</includeSchemaBindings>
<options>
<package>com.generated.xml.searchhotel</package>
</options>
</configuration>
</execution>
<execution>
<id>compile-binding</id>
<goals>
<goal>bind</goal>
</goals>
<configuration>
<schemaBindingDirectory>src/main/java</schemaBindingDirectory>
<includes>
<include>binding.xml</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
As you can see the POJOs are generated, the binding.xml is generated but the bind is not being run for some reason?
Need to add another plug in that points to 1.5 or above for some reason maven 2 plugins are compiling against 1.3. Was causing the binding problem which uses generics.
I added the following to my plugin
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<compilerArgument></compilerArgument>
</configuration>
</plugin>