You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/08/31 22:07:41 UTC
svn commit: r1806875 - in /sling/trunk/tooling/maven: ./
javaversion-maven-plugin/ javaversion-maven-plugin/src/
javaversion-maven-plugin/src/main/ javaversion-maven-plugin/src/main/java/
javaversion-maven-plugin/src/main/java/org/ javaversion-maven-pl...
Author: rombert
Date: Thu Aug 31 22:07:41 2017
New Revision: 1806875
URL: http://svn.apache.org/viewvc?rev=1806875&view=rev
Log:
SLING-7072 - Build failure with Java 9 - unable to create javax script
engine for javascript
Added a basic javaversion-maven-plugin
Added:
sling/trunk/tooling/maven/javaversion-maven-plugin/
sling/trunk/tooling/maven/javaversion-maven-plugin/pom.xml
sling/trunk/tooling/maven/javaversion-maven-plugin/src/
sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/
sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/java/
sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/java/org/
sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/java/org/apache/
sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/java/org/apache/sling/
sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/java/org/apache/sling/maven/
sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/java/org/apache/sling/maven/javaversion/
sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/java/org/apache/sling/maven/javaversion/SetJavaVersionMojo.java
sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/resources/
sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/resources/META-INF/
sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/resources/META-INF/m2e/
sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
Modified:
sling/trunk/tooling/maven/pom.xml
Added: sling/trunk/tooling/maven/javaversion-maven-plugin/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/javaversion-maven-plugin/pom.xml?rev=1806875&view=auto
==============================================================================
--- sling/trunk/tooling/maven/javaversion-maven-plugin/pom.xml (added)
+++ sling/trunk/tooling/maven/javaversion-maven-plugin/pom.xml Thu Aug 31 22:07:41 2017
@@ -0,0 +1,107 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>31</version>
+ </parent>
+
+
+ <artifactId>javaversion-maven-plugin</artifactId>
+ <packaging>maven-plugin</packaging>
+ <version>0.0.1-SNAPSHOT</version>
+ <name>Java version Maven plugin</name>
+
+ <properties>
+ <maven.version>3.0.5</maven.version>
+ <!-- should be set to the lowest version supported by the plugin -->
+ <sling.java.version>6</sling.java.version>
+ </properties>
+
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-core</artifactId>
+ <version>${maven.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.plugin-tools</groupId>
+ <artifactId>maven-plugin-annotations</artifactId>
+ <version>3.4</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-metadata</artifactId>
+ <version>1.5.5</version>
+ <executions>
+ <execution>
+ <id>generate-metadata</id>
+ <goals>
+ <goal>generate-metadata</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>mojo-descriptor</id>
+ <phase>process-classes</phase>
+ <goals>
+ <goal>descriptor</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>generated-helpmojo</id>
+ <goals>
+ <goal>helpmojo</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-plugin-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>
Added: sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/java/org/apache/sling/maven/javaversion/SetJavaVersionMojo.java
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/java/org/apache/sling/maven/javaversion/SetJavaVersionMojo.java?rev=1806875&view=auto
==============================================================================
--- sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/java/org/apache/sling/maven/javaversion/SetJavaVersionMojo.java (added)
+++ sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/java/org/apache/sling/maven/javaversion/SetJavaVersionMojo.java Thu Aug 31 22:07:41 2017
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.maven.javaversion;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.apache.maven.project.MavenProject;
+
+/**
+ * Sets Maven project properties in accordance to the specified <tt>sling.java.version</tt> property
+ *
+ * <p>The following versions are set:
+ * <ol>
+ * <li><tt>sling.bree</tt> - the value of the OSGi Bundle-RequiredExecutionEnvironment header.
+ * <li><tt>sling.animalSignatures.version</tt> - the value
+ * </ol>
+ * </p>
+ *
+ */
+@Mojo(name = "set-java-version", defaultPhase = LifecyclePhase.INITIALIZE)
+public class SetJavaVersionMojo extends AbstractMojo {
+
+ /**
+ * Java version, without the leading '1.', e.g. <em>8</em>
+ */
+ @Parameter(property = "sling.java.version")
+ private String javaVersion;
+
+ @Parameter(property = "project", readonly = true, required = true)
+ private MavenProject project;
+
+ private final Map<String, String> javaVersionToBree = new HashMap<String,String>();
+ {
+ javaVersionToBree.put("6", "JavaSE-1.6");
+ javaVersionToBree.put("7", "JavaSE-1.7");
+ javaVersionToBree.put("8", "JavaSE-1.8");
+ }
+
+ public void execute() throws MojoExecutionException {
+
+ String bree = javaVersionToBree.get(javaVersion);
+
+ if ( bree == null )
+ throw new MojoExecutionException("Invalid javaVersion: " + javaVersion + ". Expected one of " + javaVersionToBree.keySet());
+
+ project.getProperties().setProperty("sling.bree", bree);
+ project.getProperties().setProperty("sling.animalSignatures.version", javaVersion);
+
+ getLog().info("Setting Bundle-RequiredExecutionEnvironment=" + bree + " from sling.java.version=" + javaVersion);
+ }
+}
Added: sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml?rev=1806875&view=auto
==============================================================================
--- sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml (added)
+++ sling/trunk/tooling/maven/javaversion-maven-plugin/src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml Thu Aug 31 22:07:41 2017
@@ -0,0 +1,32 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<lifecycleMappingMetadata>
+ <pluginExecutions>
+ <pluginExecution>
+ <pluginExecutionFilter>
+ <goals>
+ <goal>set-java-version</goal>
+ </goals>
+ </pluginExecutionFilter>
+ <action>
+ <execute/>
+ </action>
+ </pluginExecution>
+ </pluginExecutions>
+</lifecycleMappingMetadata>
Modified: sling/trunk/tooling/maven/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/tooling/maven/pom.xml?rev=1806875&r1=1806874&r2=1806875&view=diff
==============================================================================
--- sling/trunk/tooling/maven/pom.xml (original)
+++ sling/trunk/tooling/maven/pom.xml Thu Aug 31 22:07:41 2017
@@ -63,6 +63,7 @@
<modules>
<module>apache-sling-jar-resource-bundle</module>
+ <module>javaversion-maven-plugin</module>
<module>maven-jcrocm-plugin</module>
<module>maven-jspc-plugin</module>
<module>maven-sling-plugin</module>