Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ethlo committed Sep 2, 2019
1 parent 5408055 commit 62d98c0
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 86 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea
*.iml
.classpath
.project
.settings
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ethlo.persistence.tools</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
package com.ethlo.persistence.tools.eclipselink;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.Properties;

import javax.persistence.SharedCacheMode;
import javax.persistence.ValidationMode;
import javax.persistence.spi.ClassTransformer;
import javax.persistence.spi.PersistenceUnitInfo;
import javax.persistence.spi.PersistenceUnitTransactionType;
import javax.sql.DataSource;

/*-
* #%L
Expand All @@ -11,9 +21,9 @@
* Licensed 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.
Expand All @@ -22,17 +32,6 @@
* #L%
*/

import java.net.URL;
import java.util.List;
import java.util.Properties;

import javax.persistence.SharedCacheMode;
import javax.persistence.ValidationMode;
import javax.persistence.spi.ClassTransformer;
import javax.persistence.spi.PersistenceUnitInfo;
import javax.persistence.spi.PersistenceUnitTransactionType;
import javax.sql.DataSource;

public class DelegatingPuInfo implements PersistenceUnitInfo
{
private final PersistenceUnitInfo delegate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,11 @@ public void execute() throws MojoExecutionException
catch (Exception e)
{
throw new MojoExecutionException(e.getMessage(), e);
}
finally
} finally
{
thread.setContextClassLoader(currentClassLoader);
}

getLog().info("Eclipselink DDL completed");
}
}
Expand Down Expand Up @@ -178,8 +177,7 @@ private ClassLoader getClassLoader() throws MojoExecutionException
{
try
{
@SuppressWarnings("unchecked")
final List<String> classpathElements = project.getCompileClasspathElements();
@SuppressWarnings("unchecked") final List<String> classpathElements = project.getCompileClasspathElements();
getLog().debug("Classpath URLs: " + StringUtils.collectionToCommaDelimitedString(classpathElements));
final List<URL> projectClasspathList = new ArrayList<>();
for (String element : classpathElements)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed 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.
Expand Down Expand Up @@ -59,44 +59,35 @@
/**
* @author Morten Haraldsen
*/
@Mojo(requiresDependencyResolution=ResolutionScope.COMPILE, defaultPhase=LifecyclePhase.GENERATE_SOURCES, name="modelgen", requiresProject=true)
@Mojo(requiresDependencyResolution = ResolutionScope.COMPILE, defaultPhase = LifecyclePhase.GENERATE_SOURCES, name = "modelgen", requiresProject = true)
public class EclipselinkModelGenMojo extends AbstractMojo
{
public static final String PLUGIN_PREFIX = "JPA modelgen: ";
public static final String JAVA_FILE_FILTER = "/*.java";
public static final String[] ALL_JAVA_FILES_FILTER = new String[] { "**" + JAVA_FILE_FILTER };

public static final String[] ALL_JAVA_FILES_FILTER = new String[]{"**" + JAVA_FILE_FILTER};
// Use Hibernate's model generator as it does not require persistence.xml file to run
private final String processor = org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor.class.getName();
@Parameter(defaultValue = "${project}", readonly = true, required = true)
protected MavenProject project;
@Component
private BuildContext buildContext;

/**
* A list of inclusion package filters for the apt processor.
* If not specified all sources will be used
*/
@Parameter
private Set<String> includes = new HashSet<String>();

@Parameter(defaultValue="${project.build.sourceDirectory}", required=true)
@Parameter(defaultValue = "${project.build.sourceDirectory}", required = true)
private File source;

@Parameter(defaultValue="${project.build.directory}/generated-sources/apt")
@Parameter(defaultValue = "${project.build.directory}/generated-sources/apt")
private File generatedSourcesDirectory;

@Parameter(defaultValue="${project.build.sourceEncoding}")
@Parameter(defaultValue = "${project.build.sourceEncoding}")
private String encoding;

private boolean verbose = false;
private boolean noWarn = false;

@Parameter( defaultValue = "${project}", readonly = true, required=true)
protected MavenProject project;

@Parameter(defaultValue="false", property="eclipselink.modelgen.skip")
@Parameter(defaultValue = "false", property = "eclipselink.modelgen.skip")
private boolean skip;

// Use Hibernate's model generator as it does not require persistence.xml file to run
private final String processor = org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor.class.getName();

private List<File> getCurrentClassPath()
{
final List<File> retVal = new ArrayList<>();
Expand Down Expand Up @@ -183,7 +174,7 @@ public void execute() throws MojoExecutionException, MojoFailureException
{
s.append("\n" + diagnostic);
}

if (!retVal)
{
throw new MojoExecutionException("Processing failed: " + s.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ public class EclipselinkStaticWeaveMojo extends AbstractMojo

@Parameter(defaultValue = "${project}", readonly = true, required = true)
private MavenProject project;

@Parameter(defaultValue = "true")
private boolean addClassesToPersistenceFile;


@Parameter(defaultValue = "false", property = "eclipselink.weave.skip")
private boolean skip;

@Override
public void execute() throws MojoExecutionException
{
Expand Down Expand Up @@ -161,9 +161,9 @@ private void processPersistenceXml(ClassLoader classLoader, Set<String> entityCl
final Document doc = targetFile.exists() ? PersistenceXmlHelper.parseXml(targetFile) : PersistenceXmlHelper.createXml(name);

checkExisting(targetFile, classLoader, doc, entityClasses);
if(addClassesToPersistenceFile)
if (addClassesToPersistenceFile)
{
PersistenceXmlHelper.appendClasses(doc, entityClasses);
PersistenceXmlHelper.appendClasses(doc, entityClasses);
}
PersistenceXmlHelper.outputXml(doc, targetFile);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
* Licensed 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.
Expand Down Expand Up @@ -52,7 +52,6 @@
import org.xml.sax.SAXException;

/**
*
* @author Morten Haraldsen
*/
public class PersistenceXmlHelper
Expand Down
56 changes: 28 additions & 28 deletions src/main/resources/META-INF/m2e/lifecycle-mapping-metadata.xml
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<goals>
<goal>weave</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
<runOnConfiguration>true</runOnConfiguration>
</execute>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<goals>
<goal>modelgen</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
<runOnConfiguration>true</runOnConfiguration>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<goals>
<goal>weave</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
<runOnConfiguration>true</runOnConfiguration>
</execute>
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<goals>
<goal>modelgen</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute>
<runOnIncremental>true</runOnIncremental>
<runOnConfiguration>true</runOnConfiguration>
</execute>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
20 changes: 10 additions & 10 deletions src/main/resources/empty-persistence.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<properties>
<property name="eclipselink.weaving" value="static" />
</properties>
</persistence-unit>
<persistence xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="" transaction-type="RESOURCE_LOCAL">
<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
<properties>
<property name="eclipselink.weaving" value="static"/>
</properties>
</persistence-unit>
</persistence>

0 comments on commit 62d98c0

Please sign in to comment.