mirror of https://github.com/apache/openjpa.git
OPENJPA-1934: Cleanup compiler warnings.
git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1091279 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
8544f5da4a
commit
d20b9a9511
|
@ -26,6 +26,7 @@ import org.codehaus.plexus.util.FileUtils;
|
|||
import org.apache.openjpa.enhance.PCEnhancer;
|
||||
import org.apache.openjpa.lib.util.Options;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -89,7 +90,7 @@ public abstract class AbstractOpenJpaEnhancerMojo extends AbstractOpenJpaMojo {
|
|||
FileUtils.mkdir(getEntityClasses().getAbsolutePath());
|
||||
}
|
||||
|
||||
List entities = findEntityClassFiles();
|
||||
List<File> entities = findEntityClassFiles();
|
||||
|
||||
enhance(entities);
|
||||
}
|
||||
|
@ -117,7 +118,7 @@ public abstract class AbstractOpenJpaEnhancerMojo extends AbstractOpenJpaMojo {
|
|||
* @param files class file resources to enhance.
|
||||
* @throws MojoExecutionException if the enhancer encountered a failure
|
||||
*/
|
||||
private void enhance(List files) throws MojoExecutionException {
|
||||
private void enhance(List<File> files) throws MojoExecutionException {
|
||||
Options opts = getOptions();
|
||||
|
||||
// list of input files
|
||||
|
|
|
@ -19,10 +19,15 @@
|
|||
package org.apache.openjpa.tools.maven;
|
||||
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.plugin.MojoFailureException;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
import org.apache.openjpa.enhance.PersistenceCapable;
|
||||
import org.apache.openjpa.jdbc.conf.JDBCConfiguration;
|
||||
import org.apache.openjpa.jdbc.conf.JDBCConfigurationImpl;
|
||||
|
@ -31,14 +36,7 @@ import org.apache.openjpa.lib.conf.Configurations;
|
|||
import org.apache.openjpa.lib.meta.ClassArgParser;
|
||||
import org.apache.openjpa.lib.util.Options;
|
||||
import org.apache.openjpa.meta.MetaDataRepository;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
/**
|
||||
* Processes Application model classes and generate the DDL by running the
|
||||
|
@ -78,7 +76,7 @@ public abstract class AbstractOpenJpaMappingToolMojo extends AbstractOpenJpaMojo
|
|||
FileUtils.mkdir(getEntityClasses().getAbsolutePath());
|
||||
}
|
||||
|
||||
List entities = findEntityClassFiles();
|
||||
List<File> entities = findEntityClassFiles();
|
||||
|
||||
mappingTool(entities);
|
||||
}
|
||||
|
@ -90,7 +88,7 @@ public abstract class AbstractOpenJpaMappingToolMojo extends AbstractOpenJpaMojo
|
|||
* @param files class file resources to map.
|
||||
* @throws MojoExecutionException if the MappingTool detected an error
|
||||
*/
|
||||
private void mappingTool(List files) throws MojoExecutionException {
|
||||
private void mappingTool(List<File> files) throws MojoExecutionException {
|
||||
extendRealmClasspath();
|
||||
|
||||
Options opts = getOptions();
|
||||
|
@ -126,23 +124,20 @@ public abstract class AbstractOpenJpaMappingToolMojo extends AbstractOpenJpaMojo
|
|||
* @param files List with classPath Files; non persistence classes will be removed
|
||||
* @param opts filled configuration Options
|
||||
*/
|
||||
private void filterPersistenceCapable(List files, Options opts) {
|
||||
private void filterPersistenceCapable(List<File> files, Options opts) {
|
||||
JDBCConfiguration conf = new JDBCConfigurationImpl();
|
||||
Configurations.populateConfiguration(conf, opts);
|
||||
MetaDataRepository repo = conf.newMetaDataRepositoryInstance();
|
||||
ClassArgParser cap = repo.getMetaDataFactory().newClassArgParser();
|
||||
|
||||
Iterator fileIt = files.iterator();
|
||||
while (fileIt.hasNext()) {
|
||||
File classPath = (File) fileIt.next();
|
||||
|
||||
Class[] classes = cap.parseTypes(classPath.getAbsolutePath());
|
||||
for(File classPath : files) {
|
||||
Class<?>[] classes = cap.parseTypes(classPath.getAbsolutePath());
|
||||
|
||||
if (classes == null) {
|
||||
getLog().info("Found no classes for " + classPath.getAbsolutePath());
|
||||
} else {
|
||||
for (int i = 0; i < classes.length; i++) {
|
||||
Class cls = classes[i];
|
||||
Class<?> cls = classes[i];
|
||||
|
||||
if (cls.getAnnotation(Entity.class) != null) {
|
||||
getLog().debug("Found @Entity in class " + classPath);
|
||||
|
@ -151,7 +146,6 @@ public abstract class AbstractOpenJpaMappingToolMojo extends AbstractOpenJpaMojo
|
|||
+ PersistenceCapable.class.getName());
|
||||
} else {
|
||||
getLog().debug("Removing non-entity class " + classPath);
|
||||
fileIt.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -163,9 +157,9 @@ public abstract class AbstractOpenJpaMappingToolMojo extends AbstractOpenJpaMojo
|
|||
* @param cls the Class to check
|
||||
* @return <code>true</code> if the given Class cls implements the interface {@link PersistenceCapable}
|
||||
*/
|
||||
private boolean implementsPersistenceCapable(Class cls) {
|
||||
private boolean implementsPersistenceCapable(Class<?> cls) {
|
||||
boolean isPersistenceCapable = false;
|
||||
Class[] interfaces = cls.getInterfaces();
|
||||
Class<?>[] interfaces = cls.getInterfaces();
|
||||
for (int i = 0; i < interfaces.length; i++) {
|
||||
if (interfaces[i].getName().equals(PersistenceCapable.class.getName())) {
|
||||
isPersistenceCapable = true;
|
||||
|
|
|
@ -25,16 +25,14 @@ import java.net.MalformedURLException;
|
|||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.plugin.AbstractMojo;
|
||||
import org.apache.maven.plugin.MojoExecutionException;
|
||||
import org.apache.maven.project.MavenProject;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
import org.apache.openjpa.lib.util.Options;
|
||||
import org.codehaus.plexus.util.FileUtils;
|
||||
|
||||
/**
|
||||
* Base class for OpenJPA maven tasks.
|
||||
|
@ -141,7 +139,7 @@ public abstract class AbstractOpenJpaMojo extends AbstractMojo
|
|||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
protected List compileClasspathElements;
|
||||
protected List<String> compileClasspathElements;
|
||||
|
||||
/**
|
||||
* Setting this parameter to <code>true</code> will force
|
||||
|
@ -199,7 +197,7 @@ public abstract class AbstractOpenJpaMojo extends AbstractMojo
|
|||
* This function retrieves the injected classpath elements for the current mojo.
|
||||
* @return List of classpath elements for the compile phase
|
||||
*/
|
||||
protected List getClasspathElements()
|
||||
protected List<String> getClasspathElements()
|
||||
{
|
||||
return compileClasspathElements;
|
||||
}
|
||||
|
@ -278,11 +276,10 @@ public abstract class AbstractOpenJpaMojo extends AbstractMojo
|
|||
protected void extendRealmClasspath()
|
||||
throws MojoExecutionException
|
||||
{
|
||||
List urls = new ArrayList();
|
||||
List<URL> urls = new ArrayList<URL>();
|
||||
|
||||
for ( Iterator itor = getClasspathElements().iterator(); itor.hasNext(); )
|
||||
{
|
||||
File pathElem = new File( (String) itor.next() );
|
||||
for(String fileName: getClasspathElements()) {
|
||||
File pathElem = new File(fileName);
|
||||
try
|
||||
{
|
||||
URL url = pathElem.toURI().toURL();
|
||||
|
@ -310,13 +307,13 @@ public abstract class AbstractOpenJpaMojo extends AbstractMojo
|
|||
* @throws MojoExecutionException if there was an error scanning class file
|
||||
* resources.
|
||||
*/
|
||||
protected List findEntityClassFiles() throws MojoExecutionException
|
||||
protected List<File> findEntityClassFiles() throws MojoExecutionException
|
||||
{
|
||||
List files = new ArrayList();
|
||||
List<File> files = new ArrayList<File>();
|
||||
|
||||
try
|
||||
{
|
||||
files = FileUtils.getFiles( getEntityClasses(), includes, excludes );
|
||||
files = (List<File>) FileUtils.getFiles( getEntityClasses(), includes, excludes );
|
||||
}
|
||||
catch ( IOException e )
|
||||
{
|
||||
|
@ -331,12 +328,12 @@ public abstract class AbstractOpenJpaMojo extends AbstractMojo
|
|||
* @param files List of files
|
||||
* @return the paths of the given files as String[]
|
||||
*/
|
||||
protected String[] getFilePaths( List files )
|
||||
protected String[] getFilePaths( List<File> files )
|
||||
{
|
||||
String[] args = new String[ files.size() ];
|
||||
for ( int i = 0; i < files.size(); i++ )
|
||||
{
|
||||
File file = (File) files.get( i );
|
||||
File file = files.get( i );
|
||||
|
||||
args[ i ] = file.getAbsolutePath();
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public class OpenJpaTestEnhancerMojo extends AbstractOpenJpaEnhancerMojo {
|
|||
* @required
|
||||
* @readonly
|
||||
*/
|
||||
protected List testClasspathElements;
|
||||
protected List<String> testClasspathElements;
|
||||
|
||||
/**
|
||||
* This is where compiled test classes go.
|
||||
|
@ -70,7 +70,7 @@ public class OpenJpaTestEnhancerMojo extends AbstractOpenJpaEnhancerMojo {
|
|||
*
|
||||
* @return List of classpath elements for the test phase
|
||||
*/
|
||||
protected List getClasspathElements() {
|
||||
protected List<String> getClasspathElements() {
|
||||
return testClasspathElements;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public class OpenJpaEnhancerMojoTest extends AbstractMojoTestCase {
|
|||
assertNotNull( mojo );
|
||||
|
||||
mojo.classes = new File( getBasedir(), "target/test-classes/" );
|
||||
mojo.compileClasspathElements = new ArrayList();
|
||||
mojo.compileClasspathElements = new ArrayList<String>();
|
||||
mojo.compileClasspathElements.add( mojo.classes.getAbsolutePath() );
|
||||
|
||||
mojo.execute();
|
||||
|
|
Loading…
Reference in New Issue