Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alfresco 6.0 support #196

Merged
merged 17 commits into from Mar 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 10 additions & 4 deletions .travis.yml
@@ -1,16 +1,22 @@
sudo: required
language: java
addons:
apt:
packages:
- docker-ce

jdk:
- oraclejdk8
- oraclejdk8

services:
- docker

script:
- ./gradlew build test
- ./gradlew check

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
- $HOME/.gradle/wrapper/
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -24,7 +24,8 @@ Version template:
## [2.0.0] - UNRELEASED
### Changed
* Build process refactored to build and compile for specific Alfresco versions

### Added
* Alfresco 6 support

## [1.7.6] - 2018-09-05
* [#189](https://github.com/xenit-eu/dynamic-extensions-for-alfresco/issues/189) Support Json 2 on Alfresco 4
Expand Down
8 changes: 6 additions & 2 deletions README.md
Expand Up @@ -13,8 +13,8 @@ Installing Dynamic Extensions

To make sure Dynamic Extensions is build and compiled against the correct
Alfresco version, build artifacts for each minor Alfresco version update
are distributed. E.g. if you are working with Alfresco 5.2.f, you should
use the `alfresco-dynamic-extensions-repo-52` artifact.
are distributed. E.g. if you are working with Alfresco 6.0.7-ga, you should
use the `alfresco-dynamic-extensions-repo-60` artifact.

Dynamic Extensions is distributed as an Alfresco Module Package (AMP).

Expand All @@ -38,6 +38,10 @@ Dynamic Extensions is distributed as an Alfresco Module Package (AMP).
Supported Alfresco versions
---------------------------

Dynamic Extensions is systematically integration tested against:

* Alfresco Community 6.0

Dynamic Extensions is developed and tested against:

* Alfresco Enterprise 4.1
Expand Down
@@ -0,0 +1,8 @@
dependencies {
blueprint("org.eclipse.gemini:org.eclipse.gemini.blueprint.core:1.0.2.RELEASE") {
transitive = false
}
blueprint("org.eclipse.gemini:org.eclipse.gemini.blueprint.io:1.0.2.RELEASE") {
transitive = false
}
}
@@ -0,0 +1,8 @@
dependencies {
blueprint("org.eclipse.gemini:org.eclipse.gemini.blueprint.core:1.0.2.RELEASE") {
transitive = false
}
blueprint("org.eclipse.gemini:org.eclipse.gemini.blueprint.io:1.0.2.RELEASE") {
transitive = false
}
}
@@ -0,0 +1,8 @@
dependencies {
blueprint("org.eclipse.gemini:org.eclipse.gemini.blueprint.core:1.0.2.RELEASE") {
transitive = false
}
blueprint("org.eclipse.gemini:org.eclipse.gemini.blueprint.io:1.0.2.RELEASE") {
transitive = false
}
}
@@ -0,0 +1,7 @@
module.id = ${project.parent.name}
module.version = ${project.version.replace('-SNAPSHOT','')}
module.title = Dynamic Extensions for Alfresco ${project.ext.simpleAlfrescoVersion}
module.description = Dynamic Extensions for Alfresco module package

module.repo.version.min=6.0.0
module.repo.version.max=6.0.99
42 changes: 23 additions & 19 deletions alfresco-dynamic-extensions-repo/build.gradle
Expand Up @@ -2,39 +2,35 @@ subprojects {
group "eu.xenit"

configurations {
amp
compile.extendsFrom(amp)
ampArtifact
ampLib
compile.extendsFrom(ampLib)
blueprint
bundles
}

dependencies {
implementation "${project.ext.alfrescoBom}"

amp(project(":alfresco-integration:alfresco-integration-${project.ext.simpleAlfrescoVersion}")) {
ampLib(project(":alfresco-integration:alfresco-integration-${project.ext.simpleAlfrescoVersion}")) {
transitive = false
}
amp(project(':annotations')) { transitive = false }
amp(project(":annotations-runtime:annotations-runtime-${project.ext.simpleAlfrescoVersion}")) {
ampLib(project(':annotations')) { transitive = false }
ampLib(project(":annotations-runtime:annotations-runtime-${project.ext.simpleAlfrescoVersion}")) {
transitive = false
}
amp(project(":webscripts:webscripts-${project.ext.simpleAlfrescoVersion}")) { transitive = false }
ampLib(project(":webscripts:webscripts-${project.ext.simpleAlfrescoVersion}")) { transitive = false }

amp("org.apache.felix:org.apache.felix.framework:${project.ext.felixVersion}") { transitive = false }
amp "com.springsource.util:com.springsource.util.osgi:${project.ext.springOsgiUtilVersion}"
ampLib("org.apache.felix:org.apache.felix.framework:${project.ext.felixVersion}") { transitive = false }
ampLib "com.springsource.util:com.springsource.util.osgi:${project.ext.springOsgiUtilVersion}"
// The core asm library is already included in Alfresco distributions, so we just add asm-commons.
amp("asm:asm-commons:3.1") { transitive = false }
ampLib("asm:asm-commons:3.1") { transitive = false }

amp "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
ampLib "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
ampLib "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"

amp "biz.aQute.bnd:biz.aQute.bnd:${project.ext.bndVersion}"
ampLib "biz.aQute.bnd:biz.aQute.bnd:${project.ext.bndVersion}"

blueprint("org.eclipse.gemini:org.eclipse.gemini.blueprint.core:${project.ext.geminiVersion}") {
transitive = false
}
blueprint("org.eclipse.gemini:org.eclipse.gemini.blueprint.io:${project.ext.geminiVersion}") {
transitive = false
}
blueprint(project(path: ":blueprint-override:blueprint-override-${project.ext.simpleAlfrescoVersion}", configuration: 'patch')) {
transitive = false
}
Expand All @@ -61,6 +57,13 @@ subprojects {
testCompile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
}

if(new File("${project.projectDir}/dependencies.gradle").exists()) {
// Don't use default dependencies but the ones that work with that Alfresco version
apply from: "${project.projectDir}/dependencies.gradle"
} else {
apply from: "${project.parent.projectDir}/default-dependencies.gradle"
}

def ampConfig = {
from(configurations.blueprint) {
into("config/alfresco/module/$project.parent.name/blueprint-bundles/")
Expand All @@ -70,7 +73,7 @@ subprojects {
into("config/alfresco/module/$project.parent.name/standard-bundles")
}

from(configurations.amp) {
from(configurations.ampLib) {
into("lib")
}

Expand All @@ -96,7 +99,8 @@ subprojects {
}

artifacts {
archives sourceJar, javadocJar, amp
archives sourceJar, javadocJar
ampArtifact amp
}

build.dependsOn("amp")
Expand Down
13 changes: 13 additions & 0 deletions alfresco-dynamic-extensions-repo/default-dependencies.gradle
@@ -0,0 +1,13 @@
/**
* These dependencies are overwritten for older versions of Alfresco.
* When making changes here, make sure you also take a look in the `dependencies.gradle` in the sub project's
* of older Alfresco versions.
*/
dependencies {
blueprint("org.eclipse.gemini.blueprint:gemini-blueprint-core:${project.ext.geminiVersion}") {
transitive = false
}
blueprint("org.eclipse.gemini.blueprint:gemini-blueprint-io:${project.ext.geminiVersion}") {
transitive = false
}
}
3 changes: 3 additions & 0 deletions alfresco-integration/alfresco-integration-50/build.gradle
@@ -0,0 +1,3 @@
ext {
excludedSharedFiles = ["AutowireBeanFactory.java"]
}
@@ -0,0 +1,80 @@
package com.github.dynamicextensionsalfresco.osgi.spring;

import com.github.dynamicextensionsalfresco.BeanNames;
import com.github.dynamicextensionsalfresco.annotations.AlfrescoService;
import com.github.dynamicextensionsalfresco.annotations.ServiceType;
import java.lang.annotation.Annotation;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;

/**
* {@link BeanFactory} that augments default autowiring logic by attempting to resolve dependencies using Alfresco
* naming conventions.
*
* @author Laurens Fridael
*
*/
public class AutowireBeanFactory extends DefaultListableBeanFactory {
private final Set<String> internalBeanNames = new HashSet<String>();

/* Main operations */

public AutowireBeanFactory(final BeanFactory parentBeanFactory) {
super(parentBeanFactory);

for (BeanNames beanName : BeanNames.values()) {
internalBeanNames.add(beanName.id());
}
}



@Override
protected String determinePrimaryCandidate(final Map<String, Object> candidateBeans,
final DependencyDescriptor descriptor) {
String beanName = ClassUtils.getShortName(descriptor.getDependencyType());

for (String id : candidateBeans.keySet()) {
if (internalBeanNames.contains(id)) {
return id;
}
}

final AlfrescoService alfrescoService = getAnnotation(descriptor, AlfrescoService.class);
final ServiceType serviceType = alfrescoService != null ? alfrescoService.value() : ServiceType.DEFAULT;
switch (serviceType) {
default:
// Fall through
case DEFAULT:
if (candidateBeans.containsKey(beanName)) {
return beanName;
}
// Fall through
case LOW_LEVEL:
beanName = StringUtils.uncapitalize(beanName);
if (candidateBeans.containsKey(beanName)) {
return beanName;
}
break;
}
return super.determinePrimaryCandidate(candidateBeans, descriptor);
}

/* Utility operations */

@SuppressWarnings("unchecked")
private <T extends Annotation> T getAnnotation(final DependencyDescriptor descriptor, final Class<T> annotationType) {
for (final Annotation annotation : descriptor.getAnnotations()) {
if (annotationType.isAssignableFrom(annotation.annotationType())) {
return (T) annotation;
}
}
return null;
}
}
3 changes: 3 additions & 0 deletions alfresco-integration/alfresco-integration-51/build.gradle
@@ -0,0 +1,3 @@
ext {
excludedSharedFiles = ["AutowireBeanFactory.java"]
}
@@ -0,0 +1,80 @@
package com.github.dynamicextensionsalfresco.osgi.spring;

import com.github.dynamicextensionsalfresco.BeanNames;
import com.github.dynamicextensionsalfresco.annotations.AlfrescoService;
import com.github.dynamicextensionsalfresco.annotations.ServiceType;
import java.lang.annotation.Annotation;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;

/**
* {@link BeanFactory} that augments default autowiring logic by attempting to resolve dependencies using Alfresco
* naming conventions.
*
* @author Laurens Fridael
*
*/
public class AutowireBeanFactory extends DefaultListableBeanFactory {
private final Set<String> internalBeanNames = new HashSet<String>();

/* Main operations */

public AutowireBeanFactory(final BeanFactory parentBeanFactory) {
super(parentBeanFactory);

for (BeanNames beanName : BeanNames.values()) {
internalBeanNames.add(beanName.id());
}
}



@Override
protected String determinePrimaryCandidate(final Map<String, Object> candidateBeans,
final DependencyDescriptor descriptor) {
String beanName = ClassUtils.getShortName(descriptor.getDependencyType());

for (String id : candidateBeans.keySet()) {
if (internalBeanNames.contains(id)) {
return id;
}
}

final AlfrescoService alfrescoService = getAnnotation(descriptor, AlfrescoService.class);
final ServiceType serviceType = alfrescoService != null ? alfrescoService.value() : ServiceType.DEFAULT;
switch (serviceType) {
default:
// Fall through
case DEFAULT:
if (candidateBeans.containsKey(beanName)) {
return beanName;
}
// Fall through
case LOW_LEVEL:
beanName = StringUtils.uncapitalize(beanName);
if (candidateBeans.containsKey(beanName)) {
return beanName;
}
break;
}
return super.determinePrimaryCandidate(candidateBeans, descriptor);
}

/* Utility operations */

@SuppressWarnings("unchecked")
private <T extends Annotation> T getAnnotation(final DependencyDescriptor descriptor, final Class<T> annotationType) {
for (final Annotation annotation : descriptor.getAnnotations()) {
if (annotationType.isAssignableFrom(annotation.annotationType())) {
return (T) annotation;
}
}
return null;
}
}
3 changes: 3 additions & 0 deletions alfresco-integration/alfresco-integration-52/build.gradle
@@ -0,0 +1,3 @@
ext {
excludedSharedFiles = ["AutowireBeanFactory.java"]
}