FEAT Added sample code for BAEL-3494

This commit is contained in:
Juan Moreno 2020-05-25 01:43:34 -03:00
parent 1fe51ed7c0
commit 17d2a2f052
5 changed files with 105 additions and 1 deletions

View File

@ -29,7 +29,73 @@
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>mrjar-generation</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>compile-java-8</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<source>1.8</source>
<target>1.8</target>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java8</compileSourceRoot>
</compileSourceRoots>
</configuration>
</execution>
<execution>
<id>compile-java-9</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>9</release>
<compileSourceRoots>
<compileSourceRoot>${project.basedir}/src/main/java9</compileSourceRoot>
</compileSourceRoots>
<outputDirectory>${project.build.outputDirectory}/META-INF/versions/9</outputDirectory>
</configuration>
</execution>
<execution>
<id>default-testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<skip>true</skip>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<archive>
<manifestEntries>
<Multi-Release>true</Multi-Release>
</manifestEntries>
<manifest>
<mainClass>com.baeldung.multireleaseapp.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<finalName>core-java-9-new-features</finalName>
<plugins>
@ -58,6 +124,7 @@
<junit.platform.version>1.2.0</junit.platform.version>
<maven.compiler.source>1.9</maven.compiler.source>
<maven.compiler.target>1.9</maven.compiler.target>
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
</properties>
</project>

View File

@ -0,0 +1,14 @@
package com.baeldung.multireleaseapp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class App {
private static final Logger logger = LoggerFactory.getLogger(App.class);
public static void main(String[] args) {
logger.info(String.format("Running on %s", new DefaultVersion().version()));
}
}

View File

@ -0,0 +1,9 @@
package com.baeldung.multireleaseapp;
public class DefaultVersion implements Version {
@Override
public String version() {
return System.getProperty("java.version");
}
}

View File

@ -0,0 +1,5 @@
package com.baeldung.multireleaseapp;
interface Version {
public String version();
}

View File

@ -0,0 +1,9 @@
package com.baeldung.multireleaseapp;
public class DefaultVersion implements Version {
@Override
public String version() {
return Runtime.version().toString();
}
}