Over a million developers have joined DZone.

Db4o via Maven

· Java Zone

Learn more about Kotlin, a new programming language designed to solve problems that software developers face every day brought to you in partnership with JetBrains.

I couldn't find the correct maven deps for db4o if you use transparent activation ... so here you are:

<dependencies>
<dependency>
<groupId>com.db4o</groupId>
<artifactId>db4o-full-java5</artifactId>
<version>${db4o.version}</version>
</dependency>

<dependency>
<groupId>com.db4o</groupId>
<artifactId>db4o-tools-java5</artifactId>
<version>${db4o.version}</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.db4o</groupId>
<artifactId>db4o-taj-java5</artifactId>
<version>${db4o.version}</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>com.db4o</groupId>
<artifactId>db4o-instrumentation-java5</artifactId>
<version>${db4o.version}</version>
<scope>compile</scope>
</dependency>

</dependencies>

<repositories>
<repository>
<id>db4o</id>
<name>Db4o</name>
<url>https://source.db4o.com/maven/</url>
</repository>
</repositories>

To use TA while build time you need the following snippet in your pom.xml:

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.3</version>
<dependencies>
<!-- for the regexp -->
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-nodeps</artifactId>
<version>1.7.1</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>compile</phase>
<configuration>
<tasks>
<!-- Setup the path -->
<!-- use maven.compile.classpath instead db4o.enhance.path -->

<!-- Define enhancement tasks -->
<typedef resource="instrumentation-def.properties"
classpathref="maven.compile.classpath"
loaderref="db4o.enhance.loader" />

<!-- Enhance classes which include the @Db4oPersistent annotation -->
<!--
<typedef name="annotation-filter"
classname="tacustom.AnnotationClassFilter"
classpathref="maven.compile.classpath"
loaderref="db4o.enhance.loader" /> -->

<typedef name="native-query"
classname="com.db4o.nativequery.main.NQAntClassEditFactory"
classpathref="maven.compile.classpath"
loaderref="db4o.enhance.loader" />

<!-- Instrumentation -->
<db4o-instrument classTargetDir="target/classes">
<classpath refid="maven.compile.classpath" />
<sources dir="target/classes">
<include name="**/*.class" />
</sources>

<!-- <jars refid="runtime.fileset"/> -->

<!-- Optimise Native Queries -->
<native-query-step />

<transparent-activation-step>
<!-- <annotation-filter /> -->
<regexp pattern="^de\.timefinder\.data" />
<!-- <regexp pattern="^enhancement\.model\." /> -->
</transparent-activation-step>
</db4o-instrument>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>

And you will need to configure db4o ala

config.add(new TransparentActivationSupport());

// configure db4o to use instrumenting classloader
config.reflectWith(new JdkReflector(Db4oHelper.class.getClassLoader()));
config.diagnostic().addListener(new DiagnosticListener() {

@Override
public void onDiagnostic(Diagnostic dgnstc) {
System.out.println(dgnstc.toString());
}
});

Thanks to ptrthomas! ... without his nice explanation I woudn't got it working.

From http://karussell.wordpress.com/2010/05/20/db4o-via-maven/

The Java Zone is brought to you in partnership with JetBrains.  Discover how powerful static code analysis and ergonomic design make development not only productive but also an enjoyable experience.

Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}