chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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>org.eclipse.deeplearning4j</groupId>
|
||||
<artifactId>version-updater</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<name>version-updater</name>
|
||||
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<picocli.version>4.6.1</picocli.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>2.6</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>info.picocli</groupId>
|
||||
<artifactId>picocli</artifactId>
|
||||
<version>${picocli.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<configuration>
|
||||
<mainClass>org.nd4j.VersionUpdater</mainClass>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,73 @@
|
||||
package org.nd4j;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.filefilter.IOFileFilter;
|
||||
import org.apache.commons.io.filefilter.RegexFileFilter;
|
||||
import org.apache.commons.io.filefilter.TrueFileFilter;
|
||||
import org.nd4j.fileupdater.FileUpdater;
|
||||
import org.nd4j.fileupdater.impl.CudaFileUpdater;
|
||||
import org.nd4j.fileupdater.impl.SparkFileUpdater;
|
||||
import picocli.CommandLine;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
@CommandLine.Command(name = "version-update")
|
||||
public class VersionUpdater implements Callable<Integer> {
|
||||
|
||||
@CommandLine.Option(names = {"--root-dir","-d"})
|
||||
private File filePath;
|
||||
@CommandLine.Option(names = {"--cuda-version","-c"})
|
||||
private String newCudaVersion;
|
||||
@CommandLine.Option(names = {"--cudnn-version","-cd"})
|
||||
private String newCudnnVersion;
|
||||
@CommandLine.Option(names = {"--javacpp-version","-jv"})
|
||||
private String newJavacppVersion;
|
||||
@CommandLine.Option(names = {"--update-type","-t"})
|
||||
private String updateType = "cuda";
|
||||
private FileUpdater fileUpdater;
|
||||
@CommandLine.Option(names = {"--spark-version","-sv"})
|
||||
private String sparkVersion;
|
||||
|
||||
|
||||
public static void main(String... args) {
|
||||
CommandLine commandLine = new CommandLine(new VersionUpdater());
|
||||
System.exit(commandLine.execute(args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer call() throws Exception {
|
||||
try {
|
||||
switch (updateType) {
|
||||
case "cuda":
|
||||
fileUpdater = new CudaFileUpdater(newCudaVersion, newJavacppVersion, newCudnnVersion);
|
||||
System.out.println("Updating cuda version using cuda version " + newCudaVersion + " javacpp version " + newJavacppVersion + " cudnn version " + newCudnnVersion);
|
||||
break;
|
||||
case "spark":
|
||||
fileUpdater = new SparkFileUpdater(sparkVersion);
|
||||
break;
|
||||
}
|
||||
|
||||
for (File f : FileUtils.listFilesAndDirs(filePath, new RegexFileFilter("pom.xml"), new IOFileFilter() {
|
||||
@Override
|
||||
public boolean accept(File file) {
|
||||
return !file.getName().equals("target");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(File file, String s) {
|
||||
return !file.getName().equals("target");
|
||||
}
|
||||
})) {
|
||||
if (fileUpdater.pathMatches(f)) {
|
||||
fileUpdater.patternReplace(f);
|
||||
}
|
||||
}
|
||||
}catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.nd4j.fileupdater;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Map;
|
||||
|
||||
public interface FileUpdater {
|
||||
|
||||
Map<String,String> patterns();
|
||||
|
||||
default boolean pathMatches(File inputPath) {
|
||||
if(inputPath == null)
|
||||
return false;
|
||||
return !inputPath.getParentFile().getName().equals("target") && inputPath.getName().equals("pom.xml");
|
||||
}
|
||||
|
||||
|
||||
default void patternReplace(File inputFilePath) throws IOException {
|
||||
System.out.println("Updating " + inputFilePath);
|
||||
String content = FileUtils.readFileToString(inputFilePath, Charset.defaultCharset());
|
||||
String newContent = content;
|
||||
for(Map.Entry<String,String> patternEntry : patterns().entrySet()) {
|
||||
newContent = newContent.replaceAll(patternEntry.getKey(),patternEntry.getValue());
|
||||
}
|
||||
|
||||
FileUtils.writeStringToFile(inputFilePath,newContent,Charset.defaultCharset(),false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package org.nd4j.fileupdater.impl;
|
||||
|
||||
import org.nd4j.fileupdater.FileUpdater;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class CudaFileUpdater implements FileUpdater {
|
||||
|
||||
private String cudaVersion;
|
||||
private String javacppVersion;
|
||||
private String cudnnVersion;
|
||||
|
||||
public CudaFileUpdater(String cudaVersion,String javacppVersion,String cudnnVersion) {
|
||||
this.cudaVersion = cudaVersion;
|
||||
this.javacppVersion = javacppVersion;
|
||||
this.cudnnVersion = cudnnVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,String> patterns() {
|
||||
Map<String,String> ret = new HashMap<>();
|
||||
ret.put( "\\<artifactId\\>nd4j-cuda-[0-9\\.]+\\<\\/artifactId\\>",String.format("<artifactId>nd4j-cuda-%s</artifactId>",cudaVersion));
|
||||
ret.put( "\\<artifactId\\>nd4j-cuda-[0-9\\.]*-preset<\\/artifactId\\>",String.format("<artifactId>nd4j-cuda-%s-preset</artifactId>",cudaVersion));
|
||||
ret.put( "\\<artifactId\\>nd4j-cuda-[0-9\\.]*-platform\\<\\/artifactId\\>",String.format("<artifactId>nd4j-cuda-%s-platform</artifactId>",cudaVersion));
|
||||
ret.put( "\\<cuda.version\\>[0-9\\.]*<\\/cuda.version\\>",String.format("<cuda.version>%s</cuda.version>",cudaVersion));
|
||||
ret.put( "\\<cudnn.version\\>[0-9\\.]*\\<\\/cudnn.version\\>",String.format("<cudnn.version>%s</cudnn.version>",cudnnVersion));
|
||||
ret.put( "\\<javacpp-presets.cuda.version\\>[0-9\\.]*<\\/javacpp-presets.cuda.version\\>",String.format("<javacpp-presets.cuda.version>%s</javacpp-presets.cuda.version>",javacppVersion));
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package org.nd4j.fileupdater.impl;
|
||||
|
||||
import org.nd4j.fileupdater.FileUpdater;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ScalaVersionUpdater implements FileUpdater {
|
||||
private String scalaVersion;
|
||||
@Override
|
||||
public Map<String, String> patterns() {
|
||||
Map<String, String> ret = new HashMap<>();
|
||||
ret.put("_[0-9\\.]*",scalaVersion);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.nd4j.fileupdater.impl;
|
||||
|
||||
import org.nd4j.fileupdater.FileUpdater;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SparkFileUpdater implements FileUpdater {
|
||||
|
||||
private String sparkVersion;
|
||||
|
||||
public SparkFileUpdater(String sparkVersion) {
|
||||
this.sparkVersion = sparkVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> patterns() {
|
||||
Map<String, String> ret = new HashMap<>();
|
||||
ret.put("\\<spark.version\\>[0-9\\.]*\\<\\/spark.version\\>", String.format("<spark.version>%s</spark.version>", sparkVersion));
|
||||
ret.put("\\<spark.version\\>[0-9\\.]*\\<\\/spark.version\\>", String.format("<spark.version>%s</spark.version>", sparkVersion));
|
||||
if (sparkVersion.contains("3")) {
|
||||
ret.put("\\<artifactId\\>spark_[0-9\\.]+\\<\\/artifactId\\>", "<artifactId>spark3_2.12</artifactId>");
|
||||
ret.put("\\<artifactId\\>dl4j-spark_[0-9\\.]+\\<\\/artifactId\\>", "<artifactId>dl4j-spark3_2.12</artifactId>");
|
||||
ret.put("\\<artifactId\\>datavec-spark_[0-9\\.]+\\<\\/artifactId\\>", "<artifactId>datavec-spark3_2.12</artifactId>");
|
||||
|
||||
} else {
|
||||
if (sparkVersion.contains("2")) {
|
||||
ret.put("\\<artifactId\\>spark3_[0-9\\.]+\\<\\/artifactId\\>", "<artifactId>spark_2.12</artifactId>");
|
||||
ret.put("\\<artifactId\\>dl4j-spark3_[0-9\\.]+\\<\\/artifactId\\>", "<artifactId>dl4j-spark_2.12</artifactId>");
|
||||
ret.put("\\<artifactId\\>datavec-spark3_[0-9\\.]+\\<\\/artifactId\\>", "<artifactId>datavec-spark_2.12</artifactId>");
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user