Skip to content

Commit 2817467

Browse files
Use gradle for java import tool
-Change structure of project to match gradle structure and add a package -Remove .classpath and .project -> they can be generated with gradle eclipse -Add build.gradle script With this we no longer have to manually download the required libs and run the adapt_classpath script it is all done when calling gradle build
1 parent 413d701 commit 2817467

16 files changed

+72
-124
lines changed

JavaImportTool/.classpath

-17
This file was deleted.

JavaImportTool/.gitignore

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
/lib
22
/bin
33
/test
4-
output.txt
4+
/build
5+
output.txt
6+
.gradle
7+
.idea
8+
*.iml
9+
.classpath
10+
.project
11+
.settings

JavaImportTool/.project

-17
This file was deleted.

JavaImportTool/DEPENDENCIES.txt

+4-7
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ to their License and Copyright Agreements before using them:
55
- http://commons.apache.org/proper/commons-lang/
66
- http://eclipse.org/
77

8-
The .classpath file (typically used by Eclipse) lists all dependencies:
9-
- You will need to manually download the commons-io-2.4.jar and the commons-lang3-3.1.jar into the lib directory. Newer
10-
versions might work too, as long as they provide the same interface. If you use a different version you need to adjust
11-
the .classpath file accordingly.
12-
- The rest of the dependencies come from the Eclipse JDT. You need to adjust the version of each file in
13-
.classpath in order to match what is currently installed by your Eclipse distribution. Running the adapt_classpath.sh
14-
script tries to automatically adjust the .classpath file.
8+
Since we use gradle executing gradle build or gradle eclipse will automatically download the required apache libraries.
9+
You can find gradle here:
10+
- http://gradle.org/
11+
However you still need to download and install eclipse manually.

JavaImportTool/adapt_classpath.sh

-66
This file was deleted.

JavaImportTool/build.gradle

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apply plugin: 'java'
2+
apply plugin: 'eclipse'
3+
4+
repositories {
5+
mavenCentral()
6+
}
7+
8+
def possiblePluginPaths = [
9+
'/opt/eclipse/plugins',
10+
'/usr/share/eclipse/plugins',
11+
'/usr/lib/eclipse/plugins'
12+
]
13+
14+
def pluginPath = ''
15+
possiblePluginPaths.each { it ->
16+
if (new File(it).exists()) {
17+
pluginPath = it
18+
}
19+
}
20+
21+
if (pluginPath.isEmpty()) {
22+
throw new InvalidUserDataException('No eclipse installation found')
23+
}
24+
25+
def eclipseJars = [
26+
'org.eclipse.jdt.core_*.jar',
27+
'org.eclipse.core.runtime_*.jar',
28+
'org.eclipse.core.jobs_*.jar',
29+
'org.eclipse.core.contenttype_*.jar',
30+
'org.eclipse.core.resources_*.jar',
31+
'org.eclipse.equinox.common_*.jar',
32+
'org.eclipse.equinox.preferences_*.jar',
33+
'org.eclipse.osgi_*.jar',
34+
'org.eclipse.text_*.jar'
35+
]
36+
37+
dependencies {
38+
compile (
39+
'commons-io:commons-io:2.5',
40+
'org.apache.commons:commons-lang3:3.4',
41+
fileTree (dir: pluginPath, includes: eclipseJars)
42+
)
43+
}

JavaImportTool/src/javaImportTool/ASTConverter.java JavaImportTool/src/main/java/envision/java/importtool/ASTConverter.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
**
2525
**********************************************************************************************************************/
26-
package javaImportTool;
26+
package envision.java.importtool;
2727

2828
import java.util.LinkedList;
2929
import java.util.List;
@@ -594,11 +594,12 @@ else if ( s instanceof VariableDeclarationStatement)
594594
{
595595
VariableDeclarationStatement vds = (VariableDeclarationStatement) s;
596596

597-
multipleNodes = new LinkedList<Node>();
598-
for(Node varDecl: variableDeclarationExpressions(name, vds.getType(), vds.getModifiers(),
599-
(List<IExtendedModifier>)vds.modifiers(), vds.fragments()))
597+
multipleNodes = new LinkedList<>();
598+
List<Node> varDecls = variableDeclarationExpressions(name, vds.getType(), vds.getModifiers(),
599+
(List<IExtendedModifier>)vds.modifiers(), vds.fragments());
600+
for(Node varDecl : varDecls)
600601
{
601-
// It's ok to reuse the same name for all generated variables, since this will be fixed later.
602+
// It's ok to reuse the same name for all generated variables, since this will be fixed later.
602603
Node exprStat = new Node(null,"ExpressionStatement",name);
603604
varDecl.setName("expression");
604605
exprStat.setChild("expression", varDecl);

JavaImportTool/src/javaImportTool/ConversionException.java JavaImportTool/src/main/java/envision/java/importtool/ConversionException.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
**
2525
**********************************************************************************************************************/
26-
package javaImportTool;
26+
package envision.java.importtool;
2727

2828
public class ConversionException extends Exception
2929
{

JavaImportTool/src/javaImportTool/Main.java JavaImportTool/src/main/java/envision/java/importtool/Main.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,14 @@
2323
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
**
2525
**********************************************************************************************************************/
26-
package javaImportTool;
26+
package envision.java.importtool;
2727

2828
import java.io.File;
2929
import java.io.IOException;
3030
import java.util.ArrayList;
3131
import java.util.Collection;
3232
import java.util.Map;
3333

34-
import javaImportTool.Node.OutputFormat;
35-
3634
import org.apache.commons.io.FileUtils;
3735
import org.apache.commons.io.filefilter.SuffixFileFilter;
3836
import org.apache.commons.io.filefilter.TrueFileFilter;
@@ -45,6 +43,8 @@
4543
import org.eclipse.jdt.core.util.ClassFileBytesDisassembler;
4644
import org.eclipse.jdt.core.util.ClassFormatException;
4745

46+
import envision.java.importtool.Node.OutputFormat;
47+
4848
public class Main {
4949

5050
public static void main(String[] args) {

JavaImportTool/src/javaImportTool/MethodAnalyzer.java JavaImportTool/src/main/java/envision/java/importtool/MethodAnalyzer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package javaImportTool;
1+
package envision.java.importtool;
22

33
import java.util.List;
44

JavaImportTool/src/javaImportTool/MethodMetrics.java JavaImportTool/src/main/java/envision/java/importtool/MethodMetrics.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package javaImportTool;
1+
package envision.java.importtool;
22

33
import java.util.ArrayList;
44
import java.util.List;

JavaImportTool/src/javaImportTool/Node.java JavaImportTool/src/main/java/envision/java/importtool/Node.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
**
2525
**********************************************************************************************************************/
26-
package javaImportTool;
26+
package envision.java.importtool;
2727

2828
import java.io.File;
2929
import java.io.FileNotFoundException;

JavaImportTool/src/javaImportTool/NodeDescriptors.java JavaImportTool/src/main/java/envision/java/importtool/NodeDescriptors.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
**
2525
**********************************************************************************************************************/
26-
package javaImportTool;
26+
package envision.java.importtool;
2727

2828
import java.util.HashMap;
2929
import java.util.Map;

JavaImportTool/src/javaImportTool/NodeInitializer.java JavaImportTool/src/main/java/envision/java/importtool/NodeInitializer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
**
2525
**********************************************************************************************************************/
26-
package javaImportTool;
26+
package envision.java.importtool;
2727

2828
public class NodeInitializer {
2929

JavaImportTool/src/javaImportTool/SizeEstimator.java JavaImportTool/src/main/java/envision/java/importtool/SizeEstimator.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package javaImportTool;
1+
package envision.java.importtool;
22

33
import java.util.LinkedList;
44
import java.util.List;

JavaImportTool/src/javaImportTool/UnknownFeatureException.java JavaImportTool/src/main/java/envision/java/importtool/UnknownFeatureException.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
**
2525
**********************************************************************************************************************/
26-
package javaImportTool;
26+
package envision.java.importtool;
2727

2828
public class UnknownFeatureException extends ConversionException {
2929

0 commit comments

Comments
 (0)