I am working on a new project and I need to convert several idl files using the idlpp command.
I work under IntelliJ 2020.1 using Maven.
Here is my code (just plugin exec-maven-plugin) :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>generate-source</id>
<phase>generate-sources</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>${idlpp_exec}</executable>
<workingDirectory>${gen-idl-dir}</workingDirectory>
<commandlineArgs>${example-idl}</commandlineArgs>
<commandlineArgs>${basic-idl}</commandlineArgs>
<commandlineArgs>${weather-idl}</commandlineArgs>
</configuration>
</execution>
</executions>
</plugin>
It works well on if I place a single commandlineArgs but the problem is that I have several idl files. It is possible to compile everything in a single commandlineArgs or is it impossible ??
Thanks
EDIT
I forgot to specify here is what is behind the calls ${} :
<gen-idl-dir>${project.build.directory}/generated-sources/idl/</gen-idl-dir>
<example-idl>-l java -S "../../../../IDL_Files/Chat.idl"</example-idl>
<basic-types-idl>-l java -S "../../../../IDL_Files/Basic_Types.idl"</basic-types-idl>
<common-types-idl>-l java -S "../../../../IDL_Files/Common_Types.idl"</common-types-idl>
The command <commandlineArgs>${example-idl} ${basic-types-idl}</commandlineArgs> does not work either because of the calls how I could fix that ??
Based on the plugin document, multiple arguments in commandlineArgs are separated by space,
Arguments separated by space for the executed program. For example: "-j 20"
So you should try with:
<commandlineArgs>${example-idl} ${basic-idl} ${weather-idl}</commandlineArgs>
Separate the Arguments using space. Use -j 30 or -j 10 Depending on the spaces you wish to have. This is also how we format in java except they add a % before.
Hope that helps!
Related
I'm working on a Maven Java project in VScode and I would like to use https://code.visualstudio.com/docs/java/java-linting to format and auto-correct the checkstyle errors in the source code.
I installed the extension, from command-pallet configured google_checks.xml, set checkstyle version, and then tried to trigger it from the command-palet with 'check code with checkstyle' command.
Nothing happened...
My settings.json looks as follows:
{
"java.configuration.updateBuildConfiguration": "automatic",
"java.checkstyle.configuration": "/google_checks.xml",
"java.checkstyle.version": "8.43"
}
[EDIT]
My pom.xml is:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${maven-checkstyle-plugin.version}</version>
<configuration>
<configLocation>sun_checks.xml</configLocation>
</configuration>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
I forgot to mention that it's a Maven project. I activated the Maven site command, I saw 273 errors reported, then configured the extension to sun_check.xml as well but again no result when I tried to use it.
What's missing in order to trigger this extension?
The problem was a version mismatch "java.checkstyle.version" was configured to "8.43", when I changed it to "8.18" it finally worked.
I follow the tutorial: installing Checkstyle for Java, setting configuration file, then the configuration is applied to .java file immediately:
Deleting the generated settings about checkstyle, opening Command Palette and choose the option Java: Clean Java Language Server Workspace, then try again. OR please refer to goole_checks.xml and check if your code has already met the rules.
I have a project in Windows-1254 file encoding and some of files are in UTF-8 encoding.
<properties>
<project.build.sourceEncoding>Windows-1254</project.build.sourceEncoding>
<project.reporting.outputEncoding>Windows-1254</project.reporting.outputEncoding>
<version.plugin.maven.resources>3.1.0</version.plugin.maven.resources>
<functionAppName>az-app-core</functionAppName>
</properties>
I added plugin in pom and compiles correctly with mvn compile.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<id>compile1</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<excludes>
<exclude>**/StringUtil.java</exclude>
<exclude>**/TurkceInputTag_FaceLift.java</exclude>
<exclude>**/TurkceInputTag.java</exclude>
</excludes>
<encoding>Windows-1254</encoding>
</configuration>
</execution>
<execution>
<id>compile2</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<includes>
<include>**/StringUtil.java</include>
<include>**/TurkceInputTag_FaceLift.java</include>
<include>**/TurkceInputTag.java</include>
</includes>
<encoding>UTF-8</encoding>
</configuration>
</execution>
</executions>
</plugin>
But I need to compile project by command not just clean compile but also give all configurations(defined above compile1, compile2 executions) to maven like
maven compile-plugin:compile -Dexecutions/execution1/id=compile1,encoding=Windows-1254,excludes=....
I can't change File types encoding to only UTF-8 or Windows-1254 encoding. I need to compile project using both 2 encoding.
How can maven plugin compiles by command with configurations, encoding,executions etc.?
Unfortunately the command line for Maven is not as flexible as you might like it to be for what you're wanting to achieve. (I have quite a big question about why you're trying to achieve it, and can't just specify that information in the POM as you've demonstrated).
If you look at the goal documentation for maven-compiler-plugin:compile, you'll see that some of the options, like encoding, have a 'user property'. This, prefixed with -D to make it a system property, allow you to configure it from the command line:
mvn <goals/phases> -Dencoding=... -Dmaven.compiler.failOnError=...
But running a goal from the command line will give a single execution, not the set of two that you want. So your options might be:
Run the mvn command twice, with different options on each one. Tricky though as you can't specify inclusions/exclusions.
Split the project into more than one, having different options for encoding in each, and run those from the command line.
Get around whatever limitation it is that is giving you this issue in the first place, and run from the POM as you've defined rather than on the command line.
I second khmarbaise.
All source code files in one project need to have the same encoding. Choose one and convert the other source code files.
EDIT:
You mentioned that you could not convert the files, but unfortunately, you did not tell us why.
Whatever hinders you to do it, you need to solve that issue.
So if your colleagues, managers or customers tell you not to change encoding, then you need to solve this problem by talking to these people, explaining them that a Maven project needs to have one (and just one) source code encoding and convincing them to change that.
Feel free to comment on my answer if I misunderstood you.
I am using the gwt-maven-plugin and since recently I got strange errors in my IDE (eclipse oxygen). After researching it I realize that the gwt-maven-plugin is behaving differently when run in eclipse or on commandline.
On commandline everything is ok and the gwt:css creates an interface with the correct visisbility (public). But when I run it in eclipse the public is missing and thus I get all the errors in eclipse since the classes can not access the interface anymore. I am using gwt 2.6.1, JDK 1.8.0 (but build itself is with 1.6) and maven 3.5.2.
Any ideas what is causing this?
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>gwt-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>test</goal>
<goal>css</goal>
<goal>generateAsync</goal>
<goals>
</execution>
</executions>
<configuration>
<skip>${gwt.skipcompile.config}</skip>
<inplace>true</inplace>
<module>${gwt.module.config}</module>
<runTarget>Config.html</runTarget>
<hostedWebapp>${webappDirectory}</hostedWebapp>
<extraJvmArgs>-Xmx1024M -Xss1024k</extraJvmArgs>
<compileReport>true</compileReport>
<cssFiles>
<cssFile>MyCss.css</cssFile>
</cssFiles>
//And the code is generated like this (eclipse):
interface MyCss extends CssResource ...
//in command line
public interface MyCss extends CssResource ...
The gwt-maven-plugin delegates to GWT InterfaceGenerator and it doesn't add the public modifier. You can see the git-log and confirm that this has been always the case (already reported sometimes). So, you cannot be executing the plugin goal from the command line, you should be using something different. For example, you might have a script that adds the public modifier using awk (or something similar), and this is not executed from eclipse.
Side note: You really should upgrade GWT and gwt-maven-plugin.
I see that a parameter can be configured in pom.xml or passed in the CLI such as -Dxxxxx=...
My question is if the same parameter is both configured in file pom.xml and passed in the CLI, which will be used by the maven plugin? Is there any document about this priority?
Mostly I believe CLI will override, but this real case shows the opposite.
<plugin>
<groupId>de.saumya.mojo</groupId>
<artifactId>rspec-maven-plugin</artifactId>
<version>1.0.0-beta</version>
<configuration>
<launchDirectory>${project.build.directory}/test-classes</launchDirectory>
<summaryReport>${project.build.directory}/test-Ruby.xml</summaryReport>
<specSourceDirectory>./new_test</specSourceDirectory>
</configuration>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
When I ran
mvn test -DspecSourceDirectory=./spec
The plugin still picked the specSourceDirectory in the pom.xml which is ./new_test
I'm using maven 3.0.5, java 7, jruby 1.7.5
Got it resolved: it should be a property instead of a hardcode
<specSourceDirectory>${specSourceDirectory}</specSourceDirectory>
One thing is a plugin's configuration parameter and the other thing is Maven's invocation property (user property). For example, look at Surefire's skip configuration parameter. There is a skip parameter that can be set up by maven.test.skip property. In general these 2 names are independent, so can be either different or the same.
In your case, <specSourceDirectory>${specSourceDirectory}</specSourceDirectory> will be such a latter scenario and will work as you expect.
I am currently developing a code generator, and I have built a test suite for it. The general ideia of how it is organized is depicted in the following image:
The Tests.java is a standard JUnit test class. I expect it to be on
package tests.system.bytecode.temp_tests;
as any Java developer would expect.
On the other hand, IOrderable.java and TreeSet.java are to be used by my code generator (after they are compiled to .class files, that is). But it is a bit troublesome for me to manage their current big big package declarations. The situation will only get worse as I add more tests and start to try to organize(nest) even more the tests.
It'd be perfect if IOrderable.java and TreeSet.java could have package declarations independent of their real paths, far removing future maintenance problems.
Is it possible to accomplish this with Eclipse? Maybe using Ant or Maven?
Thanks
Compiling .java classes in my Eclipse project with package declarations that don't correspond to their physical path in the project.
Should be not possible.
But you can separete the classes by different source folders.
In Eclipse you can have several source folders. When compiling they get mixed, so it would be what you need: one src folder for the normal classes and one src-gen Folder for the generated classes.
And with maven you can do the same.
There you have by default:
src/main/java
src/test/java
But you can add for example src/main/java2 or target/generated-src
Therefore you need the org.codehaus.mojo build-helper-maven-plugin. For example:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/target/generated-src</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>