Skip to content

Commit

Permalink
Enable Spring dependent extensions to work with Quarkus Spring
Browse files Browse the repository at this point in the history
Fixes #1759
  • Loading branch information
jamesnetherton committed Oct 21, 2020
1 parent b9a2528 commit aedb418
Show file tree
Hide file tree
Showing 13 changed files with 600 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml

# Eclipse
.project
Expand Down
49 changes: 49 additions & 0 deletions extensions-support/spring/README.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
= Spring Support

This extension provides common support for Camel components that depend on `org.springframework` libraries:

* spring-beans
* spring-context
* spring-core
== Repackaging of core Spring libraries

The Quarkus Spring extensions offers a limited set of supported packages for the Spring framework. This is achieved by shading the desired packages into a new quarkus-spring-*-api dependency. These can be found at the https://github.com/quarkusio/quarkus-spring-api[quarkus-spring-api] project.

A side effect of this is that the Quarkus Spring extensions enforce the exclusion of the original Spring artifacts from the build via the `quarkus-bootstrap-maven-plugin`. For example:

[source,xml]
----
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-bootstrap-maven-plugin</artifactId>
<configuration>
<excludedArtifacts>
<excludedArtifact>org.springframework:spring-core</excludedArtifact>
<excludedArtifact>org.springframework:spring-beans</excludedArtifact>
<excludedArtifact>org.springframework:spring-context</excludedArtifact>
</excludedArtifacts>
</configuration>
</plugin>
----

Therefore, in order to circumvent the artifact exclusion, the excluded Spring artifacts are shaded and repackaged with relevant packages required by various Camel extensions.

[width="100%",cols="30,70",options="header"]
|===
| Original Spring Artifact Name | Repackaged Artifact Name


| `spring-beans`
| `camel-quarkus-support-spring-beans`

| `spring-context`
| `camel-quarkus-support-spring-context`

| `spring-core`
| `camel-quarkus-support-spring-core`
|===

== Native support

This extension contains the relevant Quarkus `BuildStep`s and GraalVM substitutions that enable the Spring core libraries to work properly in native mode.
94 changes: 94 additions & 0 deletions extensions-support/spring/beans/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-spring-parent</artifactId>
<version>1.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>camel-quarkus-support-spring-beans</artifactId>
<name>Camel Quarkus :: Support :: Spring :: Beans</name>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createSourcesJar>true</createSourcesJar>
<artifactSet>
<includes>
<include>org.springframework:spring-beans</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>org.springframework:spring-beans</artifact>
<includes>
<include>META-INF/spring.factories</include>
<include>org/springframework/beans/*</include>
<include>org/springframework/beans/factory/**</include>
<include>org/springframework/beans/propertyeditors/**</include>
<include>org/springframework/beans/support/**</include>
</includes>
<excludes>
<exclude>org/springframework/beans/factory/groovy/**</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
99 changes: 99 additions & 0 deletions extensions-support/spring/context/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-spring-parent</artifactId>
<version>1.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>camel-quarkus-support-spring-context</artifactId>
<name>Camel Quarkus :: Support :: Spring :: Context</name>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createSourcesJar>true</createSourcesJar>
<artifactSet>
<includes>
<include>org.springframework:spring-context</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>org.springframework:spring-context</artifact>
<includes>
<include>org/springframework/context/*</include>
<include>org/springframework/context/event/**</include>
<include>org/springframework/context/expression/**</include>
<include>org/springframework/context/support/**</include>
<include>org/springframework/context/weaving/**</include>
<include>org/springframework/jndi/JndiCallback**</include>
<include>org/springframework/jndi/JndiTemplate.**</include>
<include>org/springframework/jndi/TypeMismatchNamingException**</include>
<include>org/springframework/scheduling/**</include>
</includes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
97 changes: 97 additions & 0 deletions extensions-support/spring/core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-support-spring-parent</artifactId>
<version>1.4.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>camel-quarkus-support-spring-core</artifactId>
<name>Camel Quarkus :: Support :: Spring :: Core</name>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-bom</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createSourcesJar>true</createSourcesJar>
<artifactSet>
<includes>
<include>org.springframework:spring-core</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>org.springframework:spring-core</artifact>
<includes>
<include>org/springframework/asm/**</include>
<include>org/springframework/core/*</include>
<include>org/springframework/core/annotation/**</include>
<include>org/springframework/core/convert/**</include>
<include>org/springframework/core/env/**</include>
<include>org/springframework/core/io/**</include>
<include>org/springframework/core/log/**</include>
<include>org/springframework/core/task/**</include>
<include>org/springframework/lang/**</include>
<include>org/springframework/util/*</include>
<include>org/springframework/util/backoff/**</include>
<include>org/springframework/util/concurrent/**</include>
<include>org/springframework/util/comparator/**</include>
<include>org/springframework/util/function/**</include>
<include>org/springframework/util/xml/**</include>
</includes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

0 comments on commit aedb418

Please sign in to comment.