Skip to content

Commit

Permalink
A preparation for the 0.3.1 release
Browse files Browse the repository at this point in the history
  • Loading branch information
v-ladynev committed Sep 8, 2016
1 parent b7fc573 commit 4356634
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 51 deletions.
14 changes: 7 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ project(':fluent-hibernate-core') {
apply plugin: 'signing'

group = "com.github.v-ladynev"
version = "0.3.0"
version = "0.3.1"
description = "Library to work with Hibernate by fluent API"
archivesBaseName = "fluent-hibernate-core"

Expand All @@ -49,7 +49,7 @@ project(':fluent-hibernate-core') {
testCompile 'com.google.guava:guava:19.0'
}

signing {
signing {
sign configurations.archives
}

Expand Down Expand Up @@ -97,17 +97,17 @@ project(':fluent-hibernate-core') {
email '[email protected]'
}
}
}.writeTo("build/libs/"+archivesBaseName+"-"+version+".pom")
}.writeTo("build/libs/" + archivesBaseName + "-" + version + ".pom")
}
}
}
}

project(':fluent-hibernate-examples').subprojects {
dependencies {
compile project(':fluent-hibernate-core')
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.37'
}
dependencies {
compile project(':fluent-hibernate-core')
compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.37'
}
}

project(':fluent-hibernate-examples:simply-console') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package com.github.fluent.hibernate.cfg.scanner;

import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.List;

import javax.persistence.Entity;

import org.hibernate.cfg.Configuration;

import com.github.fluent.hibernate.internal.util.InternalUtils;
import com.github.fluent.hibernate.internal.util.InternalUtils.Asserts;
import com.github.fluent.hibernate.internal.util.InternalUtils.ClassUtils;
import com.github.fluent.hibernate.internal.util.InternalUtils.CollectionUtils;
import org.hibernate.cfg.Configuration;

import javax.persistence.Entity;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.List;

/**
*
* @author V.Ladynev
*/
public final class EntityScanner {
Expand Down Expand Up @@ -45,8 +42,7 @@ public static EntityScanner scanAllPackages() {
/**
* Scan packages for the @Entity annotation.
*
* @param packages
* one or more Java package names
* @param packages one or more Java package names
*
* @return EntityScanner for fluent calls
*/
Expand All @@ -59,10 +55,8 @@ public static EntityScanner scanPackages(String... packages) {
/**
* Scan packages for the @Entity annotation.
*
* @param loaders
* one or more class loaders to find classes in
* @param packages
* one or more Java package names
* @param loaders one or more class loaders to find classes in
* @param packages one or more Java package names
*
* @return EntityScanner for fluent calls
*/
Expand All @@ -74,17 +68,17 @@ public static EntityScanner scanPackages(List<ClassLoader> loaders, String... pa
return scanPackages(packages, loaders, Entity.class);
}

private static EntityScanner scanPackages(String[] packages, List<ClassLoader> loaders,
Class<? extends Annotation> annotation) {
static EntityScanner scanPackages(String[] packages, List<ClassLoader> loaders,
Class<? extends Annotation> annotation) {
try {
return scanPackagesInternal(packages, loaders, annotation);
} catch (Exception ex) {
throw InternalUtils.toRuntimeException(ex);
}
}

static EntityScanner scanPackagesInternal(String[] packages, List<ClassLoader> loaders,
Class<? extends Annotation> annotation) throws Exception {
private static EntityScanner scanPackagesInternal(String[] packages, List<ClassLoader> loaders,
Class<? extends Annotation> annotation) throws Exception {
EntityScanner scanner = new EntityScanner(packages);
scanner.loaders = loaders;
scanner.scan(annotation);
Expand Down Expand Up @@ -130,8 +124,7 @@ private void addClassToResult(String resource, ClassLoader loader) throws IOExce
/**
* Adds scanned persistents to the Hibernate configuration.
*
* @param configuration
* a Hibernate configuration
* @param configuration a Hibernate configuration
*
* @return EntityScanner for fluent calls
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,5 @@
package com.github.fluent.hibernate.cfg.scanner;

import static org.assertj.core.api.Assertions.assertThat;

import java.lang.annotation.Annotation;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import javax.persistence.Entity;

import org.junit.Test;

import com.github.fluent.hibernate.cfg.scanner.jar.persistent.FirstRootEntityJar;
import com.github.fluent.hibernate.cfg.scanner.jar.persistent.NotEntityJar;
import com.github.fluent.hibernate.cfg.scanner.jar.persistent.SecondRootEntityJar;
Expand All @@ -22,9 +9,19 @@
import com.github.fluent.hibernate.cfg.scanner.persistent.NotEntity;
import com.github.fluent.hibernate.cfg.scanner.persistent.SecondRootEntity;
import com.github.fluent.hibernate.cfg.scanner.persistent.subpackage.FirstSubpackageEntity;
import org.junit.Test;

import javax.persistence.Entity;
import java.lang.annotation.Annotation;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;

/**
*
* @author V.Ladynev
*/
public class EntityScannerTest {
Expand All @@ -37,16 +34,16 @@ public class EntityScannerTest {

private static final String JAR_PACKAGE = "com.github.fluent.hibernate.cfg.scanner.jar.persistent";

private static final Class<?>[] ENTITY_CLASSES = new Class<?>[] { FirstRootEntity.class,
private static final Class<?>[] ENTITY_CLASSES = new Class<?>[]{FirstRootEntity.class,
FirstRootEntity.NestedEntity.class, SecondRootEntity.class,
FirstSubpackageEntity.class };
FirstSubpackageEntity.class};

private static final Class<?>[] OTHER_ENTITY_CLASSES = new Class<?>[] { OtherRootEntity.class,
OtherRootEntity.OtherNestedEntity.class };
private static final Class<?>[] OTHER_ENTITY_CLASSES = new Class<?>[]{OtherRootEntity.class,
OtherRootEntity.OtherNestedEntity.class};

private static final Class<?>[] JAR_ENTITY_CLASSES = new Class<?>[] { FirstRootEntityJar.class,
private static final Class<?>[] JAR_ENTITY_CLASSES = new Class<?>[]{FirstRootEntityJar.class,
FirstRootEntityJar.NestedEntityJar.class, SecondRootEntityJar.class,
FirstSubpackageEntityJar.class };
FirstSubpackageEntityJar.class};

@Test(expected = IllegalArgumentException.class)
public void withoutPackages() {
Expand Down Expand Up @@ -83,8 +80,8 @@ public void scanInJar() throws Exception {
.loadClass(Entity.class.getName());
assertThat(entityAnnotation).isNotNull();

List<Class<?>> classes = EntityScanner.scanPackagesInternal(new String[] { JAR_PACKAGE },
Arrays.<ClassLoader> asList(loader), entityAnnotation).result();
List<Class<?>> classes = EntityScanner.scanPackages(new String[]{JAR_PACKAGE},
Arrays.<ClassLoader>asList(loader), entityAnnotation).result();

assertThat(classes).contains(reload(loader, JAR_ENTITY_CLASSES))
.doesNotContain(NotEntityJar.class);
Expand Down

0 comments on commit 4356634

Please sign in to comment.