Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Convert Project to Maven #2

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ xcuserdata

dart/tests/Speedtest.dart.js.deps
dart/tests/Speedtest.dart.js.map

#Java Related
.settings/
.classpath
.project
.metadata
target/
132 changes: 132 additions & 0 deletions java/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.google</groupId>
<artifactId>diff-match-patch</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<properties>
<java-version>1.6</java-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>4.11</junit.version>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.2</version>
<configuration>
<source>${java-version}</source>
<target>${java-version}</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
</configuration>
</plugin>

<plugin>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.4</version>
<configuration>
<excludePackageNames>*.internal.*</excludePackageNames>
<failOnError>false</failOnError>
<additionalparam>-Xdoclint:none</additionalparam>
</configuration>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
<inherited>true</inherited>
</execution>
</executions>
</plugin>

<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<useDefaultManifestFile>true</useDefaultManifestFile>
<archive>
<index>true</index>
<manifest>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>

<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<surefire.useFile>false</surefire.useFile>
<includes>
<include>**/diff_match_patch_test.java</include>
<include>**/*Test</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>

<name>Google Diff Match and Patch</name>
<url>https://github.com/google/diff-match-patch</url>
<description>Diff Match Patch is a high-performance library in multiple languages that manipulates plain text.</description>
<inceptionYear>2006</inceptionYear>
<organization>
<url>https://www.google.com</url>
<name>Google Inc</name>
</organization>
<scm>
<url>https://github.com/google/diff-match-patch</url>
<connection>scm:git:git@github.com:google/diff-match-patch</connection>
<developerConnection>scm:git:git@github.com:google/diff-match-patch</developerConnection>
</scm>
<issueManagement>
<system>github.com</system>
<url>https://github.com/google/diff-match-patch/issues</url>
</issueManagement>
<developers>
<developer>
<name>Neil Fraser</name>
<organizationUrl>https://www.google.com</organizationUrl>
<url>https://www.google.com</url>
<roles>
<role>Initiator</role>
<role>Commiter</role>
</roles>
<email>fraser at google.com</email>
</developer>
</developers>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
</project>
57 changes: 57 additions & 0 deletions java/src/test/java/name/fraser/neil/plaintext/SpeedTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2010 Google Inc. All Rights Reserved.

/**
* Diff Speed Test
*
* @author fraser@google.com (Neil Fraser)
*/

package name.fraser.neil.plaintext;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;

import org.junit.Test;

public class SpeedTest {

@Test
public void testSpeed() throws Exception {
String text1 = readFile("src/test/java/name/fraser/neil/plaintext/Speedtest1.txt");
String text2 = readFile("src/test/java/name/fraser/neil/plaintext/Speedtest2.txt");

diff_match_patch dmp = new diff_match_patch();
dmp.Diff_Timeout = 0;

// Execute one reverse diff as a warmup.
dmp.diff_main(text2, text1, false);
System.gc();

long start_time = System.currentTimeMillis();
dmp.diff_main(text1, text2, false);
long end_time = System.currentTimeMillis();
System.out.printf("Elapsed time: %f\n", ((end_time - start_time) / 1000.0));
}

private static String readFile(String filename) {
// Read a file from disk and return the text contents.
StringBuffer strbuf = new StringBuffer();
try {
FileReader input = new FileReader(filename);
BufferedReader bufRead = new BufferedReader(input);
String line = bufRead.readLine();
while (line != null) {
strbuf.append(line);
strbuf.append('\n');
line = bufRead.readLine();
}

bufRead.close();

} catch (IOException e) {
e.printStackTrace();
}
return strbuf.toString();
}
}
Loading