Skip to content

Commit

Permalink
fixed combinedaccessrules issue
Browse files Browse the repository at this point in the history
  • Loading branch information
vashishthask committed Jul 23, 2012
1 parent b63c8fb commit 1d79214
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 42 deletions.
47 changes: 37 additions & 10 deletions .classpath
@@ -1,10 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/>
<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JRE-7"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Expand Up @@ -12,6 +12,7 @@ public class ClasspathConstants {
public static final String COMBINEDACCESSRULES_ATTR = "combineaccessrules";
public static final String DIR_WEB_CONTENT = "WebContent";
public static final String FILE_J2EE = ".j2ee";
public static final String EXPORTED = "exported";

private ClasspathConstants() {
// private constructor to avoid instantiation
Expand Down
Expand Up @@ -23,35 +23,61 @@ public void process(Element dependenciesElement,
Element classpathEntryElement, File workspaceRoot, Document pomDoc,
File classpathRoot) {
setupParameters(workspaceRoot, pomDoc, classpathRoot);
boolean exported = isExported(classpathEntryElement);
includeReferencedProject(dependenciesElement, classpathEntryElement);
if (exported) {
includeLibrariesOfReferencedProject(dependenciesElement, classpathEntryElement);
}
}

private void includeReferencedProject(Element dependenciesElement,
Element classpathEntryElement) {
LocalLibDependencyCreator dependencyCreator = new LocalLibDependencyCreator();
dependencyCreator.createLocalLibDependency(classpathEntryElement, dependenciesElement, pomDoc);
}

private void includeLibrariesOfReferencedProject(
Element dependenciesElement, Element classpathEntryElement) {
File referencedProjectFolder = getReferencedProjectFolder(classpathEntryElement);
if(referencedProjectFolder == null){
return;
if (referencedProjectFolder == null) {
return;
}
handleClasspathOfReferencedProject(dependenciesElement, referencedProjectFolder);
handleClasspathOfReferencedProject(dependenciesElement,
referencedProjectFolder);
}

private void handleClasspathOfReferencedProject(
Element dependenciesElement, File referencedProjectFolder) {
File classpathFile = ClasspathUtil.getClasspathFile(referencedProjectFolder);
private boolean isExported(Element classpathEntryElement) {
String exported = classpathEntryElement
.getAttribute(ClasspathConstants.EXPORTED);
if ("true".equals(exported)) {
return true;
}
return false;
}

private void handleClasspathOfReferencedProject(
Element dependenciesElement, File referencedProjectFolder) {
File classpathFile = ClasspathUtil
.getClasspathFile(referencedProjectFolder);
if (classpathFile != null) {
Document classpathDoc = XMLUtil.getDocument(classpathFile);
parseClasspathDoc(classpathDoc, dependenciesElement);
}
}
}

private void setupParameters(File workspaceRoot, Document pomDoc,
File classpathRoot) {
this.pomDoc = pomDoc;
this.workspaceRoot = workspaceRoot;
this.classpathRoot = classpathRoot;
}
private File getReferencedProjectFolder(Element classpathEntryElement){

private File getReferencedProjectFolder(Element classpathEntryElement) {
String pathAtt = classpathEntryElement
.getAttribute(ClasspathConstants.PATH_ATTR);
File folder = FileUtil.searchFolder(pathAtt, workspaceRoot);
if(folder == null){
System.err.println("Could not find folder with path:"+pathAtt);
if (folder == null) {
System.err.println("Could not find folder with path:" + pathAtt);
}
return folder;
}
Expand Down
@@ -0,0 +1,26 @@
package com.shri.eclipsetomaven.classpathentry;

import static com.shri.eclipsetomaven.ApplicationPropertyConstants.MAVEN_DEPENDENCY_GROUP_ID_DEFAULT;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

import com.shri.eclipsetomaven.pom.PomDependencyCreator;
import com.shri.eclipsetomaven.pom.PomDependencyCreatorImpl;
import com.shri.eclipsetomaven.util.ApplicationConfig;

public class LocalLibDependencyCreator {

public void createLocalLibDependency(Element classpathEntryElement, Element dependenciesElement, Document pomDoc ){
PomDependencyCreator pomDependencyCreator = new PomDependencyCreatorImpl(
pomDoc);
String pathAttribute = classpathEntryElement
.getAttribute(ClasspathConstants.PATH_ATTR);
String groupId = ApplicationConfig.INSTANCE.getValue(MAVEN_DEPENDENCY_GROUP_ID_DEFAULT);
String artifactId = pathAttribute.substring(1);
artifactId = artifactId.replaceAll("\\s", "");
pomDependencyCreator.createPomDependencyFromClasspathEntry(
dependenciesElement, pathAttribute, groupId, artifactId);
}

}
Expand Up @@ -2,15 +2,9 @@

import java.io.File;


import org.w3c.dom.Document;
import org.w3c.dom.Element;

import com.shri.eclipsetomaven.pom.PomDependencyCreator;
import com.shri.eclipsetomaven.pom.PomDependencyCreatorImpl;
import com.shri.eclipsetomaven.util.ApplicationConfig;
import static com.shri.eclipsetomaven.ApplicationPropertyConstants.*;

public class SrcWithLocalLibClasspathEntryProcessor implements
ClasspathEntryProcessor {

Expand All @@ -20,15 +14,7 @@ public class SrcWithLocalLibClasspathEntryProcessor implements
public void process(Element dependenciesElement,
Element classpathEntryElement, File workspaceRoot, Document pomDoc,
File classpathRoot) {
PomDependencyCreator pomDependencyCreator = new PomDependencyCreatorImpl(
pomDoc);
String pathAttribute = classpathEntryElement
.getAttribute(ClasspathConstants.PATH_ATTR);
String groupId = ApplicationConfig.INSTANCE.getValue(MAVEN_DEPENDENCY_GROUP_ID_DEFAULT);
String artifactId = pathAttribute.substring(1);
artifactId = artifactId.replaceAll("\\s", "");
pomDependencyCreator.createPomDependencyFromClasspathEntry(
dependenciesElement, pathAttribute, groupId, artifactId);

LocalLibDependencyCreator dependencyCreator = new LocalLibDependencyCreator();
dependencyCreator.createLocalLibDependency(classpathEntryElement, dependenciesElement, pomDoc);
}
}
10 changes: 5 additions & 5 deletions src/main/resources/application.properties
@@ -1,17 +1,17 @@
#If true, converts entire eclipse workspace into Maven workspace
convert.to.maven=false
convert.to.maven=true

#If true will remove the spaces from the project directory name. So project name say "a b c" will become "abc"
workspace.projectname.remove.space=false
workspace.projectname.remove.space=true

#If true prints, dependency graph. In order to just print the dependency graph you may want to switch off the convert.to.maven property
print.dependency.graph=true
print.dependency.graph=false
#default to file. other iotype available is "file"
print.dependency.graph.iotype=file

print.dependency.graph.filepath=/tmp/dependency.txt


maven.dependency.groupId.default=au.com.bankwest.lendnet
maven.pom.groupId.default=au.com.bankwest.lendnet
maven.dependency.groupId.default=com.github.vashishthask
maven.pom.groupId.default=com.github.vashishthask
maven.pom.version.default

0 comments on commit 1d79214

Please sign in to comment.