Skip to content

Commit

Permalink
Revert indent format
Browse files Browse the repository at this point in the history
  • Loading branch information
milkyway0308 committed Aug 18, 2023
1 parent 38968dc commit c2400a3
Showing 1 changed file with 71 additions and 72 deletions.
143 changes: 71 additions & 72 deletions src/main/java/org/bytedeco/gradle/javacpp/BuildPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ boolean isLibraryPath(String path) {
String p = (String)project.findProperty("javacpp.platform.library.path");
return p != null && p.length() > 0 ? path.startsWith(p) : path.contains("/" + getPlatform() + getPlatformExtension() + "/");
}

private <T> void setProperty(String originalMethod, String propertyField, Object target, T value) {
Method method = findMethod(target.getClass(), originalMethod, value.getClass());
if (method != null) {
Expand Down Expand Up @@ -122,7 +122,6 @@ private <T> T getProperty(String originalMethod, String propertyMethod, Object t
return ((Property<T>) invoke(propertyGetter, target)).get();
}


private Method findMethod(Class<?> cls, String methodName) {
for (Method method : cls.getMethods()) {
if (method.getName().equals(methodName)) {
Expand All @@ -147,7 +146,7 @@ private <T> T invoke(Method method, Object target, Object... parameter) {
throw new RuntimeException(e);
}
}

@Override public void apply(final Project project) {
this.project = project;
if (!project.hasProperty("javacppPlatform")) {
Expand Down Expand Up @@ -176,73 +175,73 @@ private <T> T invoke(Method method, Object target, Object... parameter) {

project.getTasks().register("javacppBuildCommand",
BuildTask.class, new Action<BuildTask>() { public void execute(BuildTask task) {
task.classPath = paths;
task.properties = getPlatform();
if (getPlatformExtension() != null && getPlatformExtension().length() > 0) {
task.propertyKeysAndValues = new Properties();
task.propertyKeysAndValues.setProperty("platform.extension", getPlatformExtension());
}
task.classOrPackageNames = new String[0];
task.workingDirectory = project.getProjectDir();
}});
task.classPath = paths;
task.properties = getPlatform();
if (getPlatformExtension() != null && getPlatformExtension().length() > 0) {
task.propertyKeysAndValues = new Properties();
task.propertyKeysAndValues.setProperty("platform.extension", getPlatformExtension());
}
task.classOrPackageNames = new String[0];
task.workingDirectory = project.getProjectDir();
}});

project.getTasks().register("javacppCompileJava",
JavaCompile.class, new Action<JavaCompile>() { public void execute(JavaCompile task) {
task.setSource(main.getJava());
task.setClasspath(main.getCompileClasspath());
setProperty(
"setDestinationDir",
"getDestinationDirectory",
task,
getProperty(
"getOutputDir",
"getDestinationDirectory",
main.getJava()
)
);
task.dependsOn("javacppBuildCommand");
}});
task.setSource(main.getJava());
task.setClasspath(main.getCompileClasspath());
setProperty(
"setDestinationDir",
"getDestinationDirectory",
task,
getProperty(
"getOutputDir",
"getDestinationDirectory",
main.getJava()
)
);
task.dependsOn("javacppBuildCommand");
}});

project.getTasks().register("javacppBuildParser",
BuildTask.class, new Action<BuildTask>() { public void execute(final BuildTask task) {
task.classPath = paths;
task.properties = getPlatform();
if (getPlatformExtension() != null && getPlatformExtension().length() > 0) {
task.propertyKeysAndValues = new Properties();
task.propertyKeysAndValues.setProperty("platform.extension", getPlatformExtension());
}
if (task.outputDirectory == null) {
task.outputDirectory = main.getJava().getSrcDirs().iterator().next();
}
task.dependsOn("javacppCompileJava");
task.doFirst(new Action<Task>() { public void execute(Task t) { main.getJava().srcDir(task.outputDirectory); }});
}});
task.classPath = paths;
task.properties = getPlatform();
if (getPlatformExtension() != null && getPlatformExtension().length() > 0) {
task.propertyKeysAndValues = new Properties();
task.propertyKeysAndValues.setProperty("platform.extension", getPlatformExtension());
}
if (task.outputDirectory == null) {
task.outputDirectory = main.getJava().getSrcDirs().iterator().next();
}
task.dependsOn("javacppCompileJava");
task.doFirst(new Action<Task>() { public void execute(Task t) { main.getJava().srcDir(task.outputDirectory); }});
}});

project.getTasks().getByName("compileJava").dependsOn("javacppBuildParser");

project.getTasks().register("javacppBuildCompiler",
BuildTask.class, new Action<BuildTask>() { public void execute(BuildTask task) {
task.classPath = paths;
task.properties = getPlatform();
if (getPlatformExtension() != null && getPlatformExtension().length() > 0) {
task.propertyKeysAndValues = new Properties();
task.propertyKeysAndValues.setProperty("platform.extension", getPlatformExtension());
}
task.dependsOn("compileJava");
}});
task.classPath = paths;
task.properties = getPlatform();
if (getPlatformExtension() != null && getPlatformExtension().length() > 0) {
task.propertyKeysAndValues = new Properties();
task.propertyKeysAndValues.setProperty("platform.extension", getPlatformExtension());
}
task.dependsOn("compileJava");
}});

project.getTasks().getByName("classes").dependsOn("javacppBuildCompiler");

project.getTasks().register("javacppPomProperties",
WriteProperties.class, new Action<WriteProperties>() { public void execute(WriteProperties task) {
Object group = project.findProperty("group");
Object name = project.findProperty("name");
Object version = project.findProperty("version");
task.property("groupId", group);
task.property("artifactId", name);
task.property("version", version);
task.setOutputFile(new File(main.getOutput().getResourcesDir(), "META-INF/maven/" + group + "/" + name + "/pom.properties"));
}});
Object group = project.findProperty("group");
Object name = project.findProperty("name");
Object version = project.findProperty("version");
task.property("groupId", group);
task.property("artifactId", name);
task.property("version", version);
task.setOutputFile(new File(main.getOutput().getResourcesDir(), "META-INF/maven/" + group + "/" + name + "/pom.properties"));
}});

Jar jarTask = (Jar)project.getTasks().getByName("jar");
jarTask.dependsOn("javacppPomProperties");
Expand All @@ -252,35 +251,35 @@ private <T> T invoke(Method method, Object target, Object... parameter) {

TaskProvider<Jar> javacppJarTask = project.getTasks().register("javacppJar",
Jar.class, new Action<Jar>() { public void execute(Jar task) {
task.from(main.getOutput());
setProperty("setClassifier", "getArchiveClassifier", task, getPlatform() + getPlatformExtension());
task.include(new Spec<FileTreeElement>() { public boolean isSatisfiedBy(FileTreeElement file) {
return file.isDirectory() || isLibraryPath(file.getPath());
}});
task.dependsOn("jar");
}});
task.from(main.getOutput());
setProperty("setClassifier", "getArchiveClassifier", task, getPlatform() + getPlatformExtension());
task.include(new Spec<FileTreeElement>() { public boolean isSatisfiedBy(FileTreeElement file) {
return file.isDirectory() || isLibraryPath(file.getPath());
}});
task.dependsOn("jar");
}});

project.getArtifacts().add("archives", javacppJarTask);

TaskProvider<Jar> javacppPlatformJarTask = project.getTasks().register("javacppPlatformJar",
Jar.class, new Action<Jar>() { public void execute(Jar task) {
setProperty("setBaseName", "getArchiveBaseName", task, project.getName() + "-platform");
task.dependsOn("javacppJar");
}});
setProperty("setBaseName", "getArchiveBaseName", task, project.getName() + "-platform");
task.dependsOn("javacppJar");
}});

TaskProvider<Jar> javacppPlatformJavadocJarTask = project.getTasks().register("javacppPlatformJavadocJar",
Jar.class, new Action<Jar>() { public void execute(Jar task) {
setProperty("setBaseName", "getArchiveBaseName", task, project.getName() + "-platform");
setProperty("setClassifier", "getArchiveClassifier", task, "javadoc");
task.dependsOn("javacppPlatformJar");
}});
setProperty("setBaseName", "getArchiveBaseName", task, project.getName() + "-platform");
setProperty("setBaseName", "getArchiveBaseName", task, project.getName() + "-platform");
task.dependsOn("javacppPlatformJar");
}});

TaskProvider<Jar> javacppPlatformSourcesTask = project.getTasks().register("javacppPlatformSourcesJar",
Jar.class, new Action<Jar>() { public void execute(Jar task) {
setProperty("setBaseName", "getArchiveBaseName", task, project.getName() + "-platform");
setProperty("setClassifier", "getArchiveClassifier", task, "sources");
task.dependsOn("javacppPlatformJar");
}});
setProperty("setBaseName", "getArchiveBaseName", task, project.getName() + "-platform");
setProperty("setClassifier", "getArchiveClassifier", task, "sources");
task.dependsOn("javacppPlatformJar");
}});

project.getConfigurations().maybeCreate("javacppPlatform");
project.getArtifacts().add("javacppPlatform", javacppPlatformJarTask);
Expand Down

0 comments on commit c2400a3

Please sign in to comment.