Merge branch 'master' of git://github.com/hibernate/hibernate-core

This commit is contained in:
JPAV 2011-03-22 14:12:21 -05:00
commit 9b06108300
15 changed files with 410 additions and 416 deletions

View File

@ -10,6 +10,17 @@ allprojects {
}
}
buildscript {
repositories {
mavenLocal()
mavenRepo name: 'jboss-nexus', urls: "https://repository.jboss.org/nexus/content/groups/public/"
mavenRepo name: "jboss-snapshots", urls: "http://snapshots.jboss.org/maven2/"
}
dependencies {
classpath 'org.hibernate.build.gradle:gradle-upload-auth-plugin:1.0.0'
}
}
ideaProject {
javaVersion = "1.6"
withXml { provider ->
@ -86,11 +97,11 @@ subprojects { subProject ->
// minimize changes, at least for now (gradle uses 'build' by default)..
buildDir = "target"
if ( ! subProject.name.startsWith( 'release' ) ) {
apply plugin: 'java'
apply plugin: 'maven' // for install task as well as deploy dependencies
apply plugin: org.hibernate.build.gradle.upload.UploadAuthenticationManager
apply plugin: 'uploadAuth'
configurations {
provided {

View File

@ -10,13 +10,22 @@ repositories {
dependencies {
// common
compile gradleApi()
compile localGroovy()
compile 'org.slf4j:slf4j-api:1.6.0'
compile 'org.apache.ant:ant:1.7.0'
compile 'org.apache.maven:maven-ant-tasks:2.1.0'
// needed?
compile 'org.apache.maven.wagon:wagon-http:1.0-beta-6'
// upload-auth plugin
compile 'dom4j:dom4j:1.6.1@jar'
// injection plugin
compile 'javassist:javassist:3.12.0.GA'
groovy localGroovy()
}

View File

@ -21,25 +21,36 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.build.gradle.upload;
package org.hibernate.build.gradle.inject;
import org.apache.maven.artifact.ant.Authentication;
import org.apache.maven.artifact.ant.RemoteRepository;
import java.util.ArrayList;
import java.util.List;
/**
* Contract for providers of {@link Authentication} details for authenticating against remote repositories.
*
* @author Steve Ebersole
*/
public interface AuthenticationProvider {
/**
* The contract method. Given a repository, determine the {@link Authentication} according to this provider's
* contract. Return {@literal null} to indicate no {@link Authentication} applied for this repository by this
* provider.
*
* @param remoteRepository The repository to check for authentication details.
*
* @return The authentication details, or {@literal null} to indicate none.
*/
public Authentication determineAuthentication(RemoteRepository remoteRepository);
public class Injection {
private final String expression;
private List<TargetMember> targetMembers = new ArrayList<TargetMember>();
public Injection(String expression) {
this.expression = expression;
}
public String getExpression() {
return expression;
}
public void into(String className, String member) {
into( new TargetMember( className, member ) );
}
public void into(TargetMember targetMember) {
targetMembers.add( targetMember );
}
public Iterable<TargetMember> getTargetMembers() {
return targetMembers;
}
}

View File

@ -0,0 +1,252 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.build.gradle.inject;
import java.io.BufferedOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.List;
import javassist.ClassPool;
import javassist.CtClass;
import javassist.CtField;
import javassist.CtMethod;
import javassist.LoaderClassPath;
import javassist.Modifier;
import javassist.NotFoundException;
import javassist.bytecode.ClassFile;
import javassist.bytecode.ConstantAttribute;
import javassist.bytecode.FieldInfo;
import org.gradle.api.Action;
import org.gradle.api.Project;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.SourceSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Steve Ebersole
*/
public class InjectionAction implements Action {
private static final Logger log = LoggerFactory.getLogger( InjectionAction.class );
private final Project project;
private List<Injection> injections = new ArrayList<Injection>();
private LoaderClassPath loaderClassPath;
private ClassPool classPool;
public InjectionAction(Project project) {
this.project = project;
}
void addInjection(Injection injection) {
injections.add( injection );
}
@Override
public void execute(Object o) {
final ClassLoader runtimeScopeClassLoader = buildRuntimeScopeClassLoader();
loaderClassPath = new LoaderClassPath( runtimeScopeClassLoader );
classPool = new ClassPool( true );
classPool.appendClassPath( loaderClassPath );
try {
performInjections();
}
finally {
loaderClassPath.close();
}
}
private ClassLoader buildRuntimeScopeClassLoader() {
final ArrayList<URL> classPathUrls = new ArrayList<URL>();
final SourceSet mainSourceSet = project
.getConvention()
.getPlugin( JavaPluginConvention.class )
.getSourceSets()
.findByName( SourceSet.MAIN_SOURCE_SET_NAME );
for ( File file : mainSourceSet.getRuntimeClasspath() ) {
try {
classPathUrls.add( file.toURI().toURL() );
}
catch (MalformedURLException e) {
throw new InjectionException( "Could not determine artifact URL [" + file.getPath() + "]", e );
}
}
return new URLClassLoader( classPathUrls.toArray( new URL[classPathUrls.size()] ), getClass().getClassLoader() );
}
private void performInjections() {
for ( Injection injection : injections ) {
for ( TargetMember targetMember : injection.getTargetMembers() ) {
resolveInjectionTarget( targetMember ).inject( injection.getExpression() );
}
}
}
private InjectionTarget resolveInjectionTarget(TargetMember targetMember) {
try {
final CtClass ctClass = classPool.get( targetMember.getClassName() );
// see if it is a field...
try {
CtField field = ctClass.getField( targetMember.getMemberName() );
return new FieldInjectionTarget( targetMember, ctClass, field );
}
catch( NotFoundException ignore ) {
}
// see if it is a method...
for ( CtMethod method : ctClass.getMethods() ) {
if ( method.getName().equals( targetMember.getMemberName() ) ) {
return new MethodInjectionTarget( targetMember, ctClass, method );
}
}
// finally throw an exception
throw new InjectionException( "Unknown member [" + targetMember.getQualifiedName() + "]" );
}
catch ( Throwable e ) {
throw new InjectionException( "Unable to resolve class [" + targetMember.getClassName() + "]", e );
}
}
/**
* Strategy for performing an injection
*/
private static interface InjectionTarget {
/**
* Inject the given value per this target's strategy.
*
* @param value The value to inject.
*
* @throws org.hibernate.build.gradle.inject.InjectionException Indicates a problem performing the injection.
*/
public void inject(String value);
}
private abstract class BaseInjectionTarget implements InjectionTarget {
@SuppressWarnings( {"UnusedDeclaration"})
private final TargetMember targetMember;
private final CtClass ctClass;
private final File classFileLocation;
protected BaseInjectionTarget(TargetMember targetMember, CtClass ctClass) {
this.targetMember = targetMember;
this.ctClass = ctClass;
try {
classFileLocation = new File( loaderClassPath.find( targetMember.getClassName() ).toURI() );
}
catch ( Throwable e ) {
throw new InjectionException( "Unable to resolve class file path", e );
}
}
@Override
public void inject(String value) {
doInjection( value );
writeOutChanges();
}
protected abstract void doInjection(String value);
protected void writeOutChanges() {
log.info( "writing injection changes back [" + classFileLocation.getAbsolutePath() + "]" );
long timeStamp = classFileLocation.lastModified();
ClassFile classFile = ctClass.getClassFile();
classFile.compact();
try {
DataOutputStream out = new DataOutputStream( new BufferedOutputStream( new FileOutputStream( classFileLocation ) ) );
try {
classFile.write( out );
out.flush();
if ( ! classFileLocation.setLastModified( System.currentTimeMillis() ) ) {
log.info( "Unable to manually update class file timestamp" );
}
}
finally {
out.close();
classFileLocation.setLastModified( timeStamp );
}
}
catch ( IOException e ) {
throw new InjectionException( "Unable to write out modified class file", e );
}
}
}
private class FieldInjectionTarget extends BaseInjectionTarget {
private final CtField ctField;
private FieldInjectionTarget(TargetMember targetMember, CtClass ctClass, CtField ctField) {
super( targetMember, ctClass );
this.ctField = ctField;
if ( ! Modifier.isStatic( ctField.getModifiers() ) ) {
throw new InjectionException( "Field is not static [" + targetMember.getQualifiedName() + "]" );
}
}
@Override
protected void doInjection(String value) {
final FieldInfo ctFieldInfo = ctField.getFieldInfo();
ctFieldInfo.addAttribute(
new ConstantAttribute(
ctFieldInfo.getConstPool(),
ctFieldInfo.getConstPool().addStringInfo( value )
)
);
}
}
private class MethodInjectionTarget extends BaseInjectionTarget {
private final CtMethod ctMethod;
private MethodInjectionTarget(TargetMember targetMember, CtClass ctClass, CtMethod ctMethod) {
super( targetMember, ctClass );
this.ctMethod = ctMethod;
}
@Override
protected void doInjection(String value) {
try {
ctMethod.setBody( "{return \"" + value + "\";}" );
}
catch ( Throwable t ) {
throw new InjectionException( "Unable to replace method body", t );
}
}
}
}

View File

@ -1,42 +1,37 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
// $Id$
package org.hibernate.cfg.annotations;
/**
* @author Emmanuel Bernard
* @deprecated Use {@link org.hibernate.Version} instead
*/
@Deprecated
public class Version {
public static String getVersionString() {
return org.hibernate.Version.getVersionString();
}
public static void touch() {
}
}
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.build.gradle.inject;
/**
* @author Steve Ebersole
*/
public class InjectionException extends RuntimeException {
public InjectionException(String message) {
super( message );
}
public InjectionException(String message, Throwable cause) {
super( message, cause );
}
}

View File

@ -21,33 +21,25 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.build.gradle.upload;
package org.hibernate.build.gradle.inject;
import java.util.LinkedList;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
/**
* A registry of {@link AuthenticationProvider} instances.
*
* @author Steve Ebersole
*/
public class AuthenticationProviderRegistry {
private final LinkedList<AuthenticationProvider> authenticationProviders = buildStandardAuthenticationProviders();
public class InjectionPlugin implements Plugin<Project> {
private static LinkedList<AuthenticationProvider> buildStandardAuthenticationProviders() {
LinkedList<AuthenticationProvider> providers = new LinkedList<AuthenticationProvider>();
providers.add( new StandardMavenAuthenticationProvider() );
return providers;
@Override
public void apply(Project project) {
final InjectionAction injectionAction = new InjectionAction( project );
// For now, just do what Hibernate needs rather than a full blown "convention" object
Injection versionInjection = new Injection( project.getVersion().toString() );
versionInjection.into( "org.hibernate.Version", "getVersionString" );
injectionAction.addInjection( versionInjection );
project.getTasks().findByName( "jar" ).doLast( injectionAction );
}
public void appendAuthenticationProvider(AuthenticationProvider provider) {
authenticationProviders.addLast( provider );
}
public void prependAuthenticationProvider(AuthenticationProvider provider) {
authenticationProviders.addFirst( provider );
}
public Iterable<AuthenticationProvider> providers() {
return authenticationProviders;
}
}

View File

@ -1,46 +1,50 @@
// $Id$
/*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
//$Id$
package org.hibernate.ejb;
import org.jboss.logging.Logger;
/**
* @author Emmanuel Bernard
*/
public class Version {
public static final EntityManagerLogger LOG = Logger.getMessageLogger(EntityManagerLogger.class, Version.class.getName());
public static String getVersionString() {
return "[WORKING]";
}
static {
LOG.entityManagerVersion(getVersionString());
}
public static void touch() {
}
}
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.build.gradle.inject;
/**
* @author Steve Ebersole
*/
public class TargetMember {
private final String className;
private final String memberName;
public TargetMember(String className, String memberName) {
this.className = className;
this.memberName = memberName;
}
public String getClassName() {
return className;
}
public String getMemberName() {
return memberName;
}
public String getQualifiedName() {
return getClassName() + "#" + getMemberName();
}
}

View File

@ -1,87 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.build.gradle.upload;
import org.apache.maven.artifact.ant.Authentication;
import org.apache.maven.artifact.ant.RemoteRepository;
import org.gradle.api.Action;
import org.gradle.api.DefaultTask;
import org.gradle.api.artifacts.maven.MavenDeployer;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.Upload;
/**
* Responsible for locating and injecting authentication information into the JBoss Nexus repository config for upload
* which it does, based on set up in
*
* @author Steve Ebersole
*/
public class AuthenticationHandler extends DefaultTask {
private AuthenticationProviderRegistry authenticationProviderRegistry;
private Upload uploadTask;
public void injectProviderRegistry(AuthenticationProviderRegistry authenticationProviderRegistry) {
this.authenticationProviderRegistry = authenticationProviderRegistry;
}
public void injectUploadTask(Upload uploadTask) {
this.uploadTask = uploadTask;
}
@TaskAction
public void configureUploadAuthentication() {
// todo : unfortunately I have no idea how to apply this to non MavenDeployer-type repos...
uploadTask.getRepositories().withType( MavenDeployer.class ).all(
new Action<MavenDeployer>() {
public void execute(MavenDeployer deployer) {
final RemoteRepository repository = deployer.getRepository();
if ( repository != null ) {
final Authentication authentication = locateAuthenticationDetails( repository );
if ( authentication != null ) {
repository.addAuthentication( authentication );
}
}
final RemoteRepository snapshotRepository = deployer.getSnapshotRepository();
if ( snapshotRepository != null ) {
final Authentication authentication = locateAuthenticationDetails( snapshotRepository );
if ( authentication != null ) {
snapshotRepository.addAuthentication( authentication );
}
}
}
}
);
}
private Authentication locateAuthenticationDetails(RemoteRepository repository) {
for ( AuthenticationProvider provider : authenticationProviderRegistry.providers() ) {
Authentication authentication = provider.determineAuthentication( repository );
if ( authentication != null ) {
return authentication;
}
}
return null;
}
}

View File

@ -1,124 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.build.gradle.upload;
import org.apache.maven.artifact.ant.Authentication;
import org.apache.maven.artifact.ant.RemoteRepository;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.xml.sax.InputSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.Iterator;
import java.util.concurrent.ConcurrentHashMap;
/**
* Provider of {@link org.apache.maven.artifact.ant.RemoteRepository} {@link Authentication} based on standard Maven
* conventions using {@literal settings.xml}.
*
* @author Steve Ebersole
*/
public class StandardMavenAuthenticationProvider implements AuthenticationProvider {
private static final Logger log = LoggerFactory.getLogger( StandardMavenAuthenticationProvider.class );
public static final String SETTINGS_LOCATION_OVERRIDE = "maven.settings";
private ConcurrentHashMap<String,Authentication> repositoryAuthenticationMap;
@Override
public Authentication determineAuthentication(RemoteRepository remoteRepository) {
if ( repositoryAuthenticationMap == null ) {
loadRepositoryAuthenticationMap();
}
return repositoryAuthenticationMap.get( remoteRepository.getId() );
}
private void loadRepositoryAuthenticationMap() {
repositoryAuthenticationMap = new ConcurrentHashMap<String, Authentication>();
final File settingsFile = determineSettingsFileLocation();
try {
InputSource inputSource = new InputSource( new FileInputStream( settingsFile ) );
try {
final Document document = buildSAXReader().read( inputSource );
final Element settingsElement = document.getRootElement();
final Element serversElement = settingsElement.element( "servers" );
final Iterator serversIterator = serversElement.elementIterator( "server" );
while ( serversIterator.hasNext() ) {
final Element serverElement = (Element) serversIterator.next();
final String id = extractValue( serverElement.element( "id" ) );
if ( id == null ) {
continue;
}
final Authentication authentication = new Authentication();
authentication.setUserName( extractValue( serverElement.element( "username" ) ) );
authentication.setPassword( extractValue( serverElement.element( "password" ) ) );
authentication.setPrivateKey( extractValue( serverElement.element( "privateKey" ) ) );
authentication.setPassphrase( extractValue( serverElement.element( "passphrase" ) ) );
repositoryAuthenticationMap.put( id, authentication );
}
}
catch (DocumentException e) {
log.error( "Error reading Maven settings.xml", e );
}
}
catch ( FileNotFoundException e ) {
log.info( "Unable to locate Maven settings.xml" );
}
}
private String extractValue(Element element) {
if ( element == null ) {
return null;
}
final String value = element.getTextTrim();
if ( value != null && value.length() == 0 ) {
return null;
}
return value;
}
private SAXReader buildSAXReader() {
SAXReader saxReader = new SAXReader();
saxReader.setMergeAdjacentText( true );
return saxReader;
}
private File determineSettingsFileLocation() {
final String overrideLocation = System.getProperty( SETTINGS_LOCATION_OVERRIDE );
return overrideLocation == null
? new File( new File( System.getProperty( "user.home" ), ".m2" ), "settings.xml" )
: new File( overrideLocation );
}
}

View File

@ -1,68 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
* Lesser General Public License, as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this distribution; if not, write to:
* Free Software Foundation, Inc.
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.build.gradle.upload;
import org.gradle.api.Action;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.tasks.Upload;
/**
* Manages authentication aspects of artifact uploading by delegation to registered {@link AuthenticationProvider}
* instances.
*
* @author Steve Ebersole
*/
public class UploadAuthenticationManager implements Plugin<Project> {
@Override
public void apply(final Project project) {
// todo : ideally the registry would be handled by a convention to allow configuration (aka, adding more providers)...
// for our purposes here in Hibernate we only care about the Maven settings.xml based way so we
// code for just that.
final AuthenticationProviderRegistry registry = new AuthenticationProviderRegistry();
project.getTasks().withType( Upload.class ).all(
new Action<Upload>() {
@Override
public void execute(final Upload uploadTask) {
// create a auth task for each upload task...
final AuthenticationHandler authenticationHandler = project.getTasks().add(
"uploadAuthenticationHandler-" + uploadTask.getName(),
AuthenticationHandler.class
);
// link the auth task with the upload task
authenticationHandler.injectUploadTask( uploadTask );
// todo: Also in conjunction, would be best to have the handler lookup the registry rather than pushing it
authenticationHandler.injectProviderRegistry( registry );
uploadTask.getDependsOn().add( authenticationHandler );
}
}
);
}
}

View File

@ -1,5 +1,6 @@
apply plugin: 'java'
apply plugin: 'antlr'
apply plugin: org.hibernate.build.gradle.inject.InjectionPlugin
dependencies {
compile( libraries.commons_collections )

View File

@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
* Copyright (c) 2009-2011, Red Hat Inc. or third-party contributors as
* indicated by the @author tags or express copyright attribution
* statements applied by the authors. All third-party contributions are
* distributed under license by Red Hat Middleware LLC.
* distributed under license by Red Hat Inc.
*
* This copyrighted material is made available to anyone wishing to use, modify,
* copy, or redistribute it subject to the terms and conditions of the GNU
@ -23,7 +23,6 @@
*/
package org.hibernate;
/**
* Information about the Hibernate version.
*
@ -34,6 +33,7 @@ public class Version {
return "[WORKING]";
}
public static void main(String[] args) {
System.out.println( "Hibernate version " + getVersionString() );
}

View File

@ -474,7 +474,7 @@ public final class SessionFactoryImpl
private Statistics buildStatistics(Settings settings, ServiceRegistry serviceRegistry) {
Statistics statistics = new ConcurrentStatisticsImpl( this );
getStatistics().setStatisticsEnabled( settings.isStatisticsEnabled() );
statistics.setStatisticsEnabled( settings.isStatisticsEnabled() );
LOG.debugf("Statistics initialized [enabled=%s]", settings.isStatisticsEnabled());
return statistics;
}

View File

@ -137,10 +137,6 @@ public class Ejb3Configuration implements Serializable, Referenceable {
}
}
static {
Version.touch();
}
private String persistenceUnitName;
private String cfgXmlResource;

View File

@ -144,10 +144,12 @@ releaseCopySpec = copySpec {
}
// todo : this closure is problematic as it does not write into the hibernate-release-$project.version directory
// asked on gradle mailing list...
// due to http://issues.gradle.org/browse/GRADLE-1450
[ 'hibernate-c3p0', 'hibernate-proxool', 'hibernate-ehcache', 'hibernate-infinispan' ].each { feature ->
final String shortName = feature.substring( 'hibernate-'.length() );
into('lib/optional/' + shortName) {
// WORKAROUND http://issues.gradle.org/browse/GRADLE-1450
// into('lib/optional/' + shortName) {
owner.into('lib/optional/' + shortName) {
from (
( parent.project( feature ).configurations.archives.allArtifactFiles.filter{ file -> !file.name.endsWith('-sources.jar') }
+ parent.project( feature ).configurations.runtime )