I'm having trouble using the official Maven Plugin and Java 7 with Google Appengine.
Configuration
My project configuration pom.xml is quite simple:
In the properties section I configure:
<gae.version>1.7.4</gae.version>
And later on I use the plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${gae.version}</version>
</plugin>
Error message
Whenever I run mvn appengine:update I get the following error:
Unable to update app: The application contains Java 7 classes, but the --use_java7 flag has not been set.
My attempt to solve it
Of course, I tried to fix this issue. Running
mvn appengine:update --use_java7
or
mvn appengine:update -D--use_java7
didn't help, because the flag is not used for the Maven plugin, but instead for the appcfg script.
How do I pass the flag to the script, so that I can use Java 7 (or is there anything else I can do)?
App Engine Java 7 Support is currently for Trusted Tester and not available to public yet, you can apply Trusted Tester at here.
Fortunately the latest official maven plugin does implement this feature, see the AbstractAppCfgMojo.java:
... ...
/**
* Use the App Engine Java 7 runtime for this app.
*
* #parameter
*/
protected boolean useJava7;
... ...
if (useJava7) {
arguments.add("--use_java7");
}
... ...
You can use the following plugin configuration in pom.xml to enable Java7 support:
</build>
<plugins>
... ...
<plugin>
<groupId>com.google.appengine</groupId>
<artifactId>appengine-maven-plugin</artifactId>
<version>${gae.version}</version>
<configuration>
<useJava7>true</useJava7>
</configuration>
</plugin>
</plugins>
</build>
Related
I am working on a project where we want to use the plexus-compiler-eclipse plugin during a Jenkins pipeline to check for increases in the number of warnings generated by the Eclipse compiler. We still want to use the javac compiler for the normal build and test stage, so I am trying to create a maven profile we can run during the warnings stage that utilizes the Eclipse compiler.
When I run the Eclipse compiler over our code, I get a compile error about JAXB dependencies being missing. I know this is due to our move to Java 11 from Java 1.8, but we do not get this error when building with the javac compiler. I have tried adding the jakarta.xml.bind-api dependency to the maven-compiler-plugin, but this does not help, nor does adding the org.glassfish.jaxb dependency or the javax.xml.bind:jaxb-api dependency.
I cannot share the full pom because this project is proprietary, but the profile I'm building looks like this:
<profile>
<id>eclipse-compile</id>
<activation>
<activeByDefault>false</activeByDefault>
</activation>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1></version>
<configuration>
<compilerId>eclipse</compilerId>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArguments>
<properties>${project.basedir}/.settings/org.eclipse.jdt.core.prefs</properties>
</compilerArguments>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-compiler-eclipse</artifactId>
<version>2.8.8</version>
</dependency>
<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>ecj</artifactId>
<version>3.25.0</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
I was putting the various JAXB dependencies I tried in the <dependencies> section under the org.eclipse.jdt entry.
Anyone else encounter this or know what to do about it?
The issue stemmed from the Maven build running in Java 11 but our normal compile stage forking to a Java 1.8 executable. Because the Plexus compiler cannot fork to a new environment, there was not a way for it to access the Java EE dependencies. We just need to update our entire project to be compatible with Java 11 at compile-time.
I am trying to run Blockhound in my Spring Boot app during testing. Unfortunately gradle does not pick up the required -XX:+AllowRedefinitionToAddDeleteMethods flag. I tried it using IntelliJ's VMoptions in Run Configurations as well as in gradle.properties org.gradle.jvmargs=-XX:+AllowRedefinitionToAddDeleteMethods. The error persists though.
Will this work?
Gradle:
tasks.withType(Test).all {
if (JavaVersion.current().isCompatibleWith​(JavaVersion.VERSION_15)) {
jvmArgs += [
"-XX:+AllowRedefinitionToAddDeleteMethods"
]
}
}
maven:
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<argLine>-XX:+AllowRedefinitionToAddDeleteMethods</argLine>
</configuration>
</plugin>
...
</plugins>
or JAVA_OPTS?
on mac/linux:
export JAVA_OPTS="-XX:+AllowRedefinitionToAddDeleteMethods"
or Windows
set JAVA_OPTS="-XX:+AllowRedefinitionToAddDeleteMethods"
reference: https://github.com/reactor/BlockHound/issues/33
oh my god, isn't it fun to compile old code...
The problem now is compiling old war with jdk6
running mvn clean package will produce following error:
[ERROR] Source option 6 is no longer supported. Use 7 or later.
[ERROR] Target option 6 is no longer supported. Use 7 or later.
Sure, i understand its bit old but this application wont compile with jdk7 ...
i have tried using targets in pom.xml
<maven.compiler.source>1.6</maven.compiler.source>
<maven.compiler.target>1.6</maven.compiler.target>
inside properties and then separately
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
Any combination of these will give same error, or im doing something wrong...
I've already had hours of fun looking packages for JDK 6 today. Please send help
I am trying to get a Rational Application Developer project to run on a websphere server. I am trying to get the maven-war-plugin to work. However, when trying to start the server, websphere can not find the UI Files. I have my plugin here:
<build>
<outputDirectory>${project.basedir}\WebContent\WEB-INF\classes</outputDirectory>
<finalName>${project.name}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<webXml>/WebContent/WEB-INF/web.xml</webXml>
<webappDirectory>WebContent</webappDirectory>
<source>/codeCoverageUI2/src/</source>
<encoding>utf-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
I feel the issue is with my webappDirectory but I do not know what else to put it to, besides the location of all my UI files.
Anyone have some insight?
I am assuming you are using WebSphere Classic V8 or earlier?
What we recommend because when developing a project in RAD/WDT, WAS Classic requires building the project in a "Single Root" structure. Add the following to your pom:
<build>
<outputDirectory>${project.basedir}\WebContent\WEB-INF\classes</outputDirectory>
<finalName>${project.name}</finalName>
...
This will build your source within the Web content folder. (Make sure you do a Project -> "Maven" -> "Update Project...") then rebuild...
I am using maven2 to build the java project, when i issue the command mvn clean install i am getting the error could not parse error message: (use -source 5 or higher to enable generics).
In my eclipse environment i am using jdk 1.7 and the project is working fine. when i want to build the project i am unable to do that, think maven is taking java version 1.3 as default.
Any one please help me how to set the jdk versio to 1.7 in maven, to build the project successfully..
Apart from the jars mentioned in pom.xml i want to add add my own jar, how can i specify that in pom xml?
Thanks in advance..
In your pom.xml configure the maven-compiler-plugin to use 1.6:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>