Skip to content

Commit

Permalink
Merge pull request #7 from techconative/spotless_added
Browse files Browse the repository at this point in the history
Spotless added
  • Loading branch information
kannangce authored Mar 20, 2023
2 parents 58c27f5 + a5ed03a commit be7c9cb
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 172 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/on-pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Java CI with Gradle

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Run chmod to make gradlew executable
run: chmod +x ./gradlew
- name: Build with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: build
- run: ./gradlew spotlessCheck
65 changes: 39 additions & 26 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id("java")
id("org.jetbrains.intellij") version "1.11.0"
id("com.diffplug.spotless") version "6.17.0"
application
}

Expand All @@ -25,6 +26,7 @@ dependencies{
implementation("org.mapstruct:mapstruct:1.5.3.Final")
// https://mvnrepository.com/artifact/org.mapstruct/mapstruct-processor
implementation("org.mapstruct:mapstruct-processor:1.5.3.Final")

}


Expand All @@ -45,37 +47,48 @@ tasks {
}
}

configurations.all {
resolutionStrategy.sortArtifacts(ResolutionStrategy.SortOrder.DEPENDENCY_FIRST)
}
configurations.all {
resolutionStrategy.sortArtifacts(ResolutionStrategy.SortOrder.DEPENDENCY_FIRST)
}

// Configure Gradle IntelliJ Plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
version.set("2022.3.1")
type.set("IC") // Target IDE Platform
plugins.set(listOf("com.intellij.java"))
}

tasks {
// Set the JVM compatibility versions
withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
intellij {
version.set("2022.3.1")
type.set("IC") // Target IDE Platform
plugins.set(listOf("com.intellij.java"))
}

patchPluginXml {
sinceBuild.set("222")
untilBuild.set("231.*")
}
tasks {
// Set the JVM compatibility versions
withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
}

signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}
patchPluginXml {
sinceBuild.set("222")
untilBuild.set("231.*")
}

signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}

publishPlugin {
token.set(System.getenv("PUBLISH_TOKEN"))
publishPlugin {
token.set(System.getenv("PUBLISH_TOKEN"))
}

spotless {
java {
googleJavaFormat()
removeUnusedImports()
palantirJavaFormat()
trimTrailingWhitespace()
endWithNewline()
}
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,19 @@
import com.intellij.util.ui.JBUI;
import com.techconative.actions.generators.GenerateMappings;
import com.techconative.actions.utilities.Utilities;
import org.jetbrains.annotations.NotNull;
import org.w3c.dom.Document;

import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import java.awt.*;
import java.io.IOException;
import java.nio.file.FileSystems;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import org.jetbrains.annotations.NotNull;
import org.w3c.dom.Document;

public class DozerTOMapperStructPlugin extends AnAction {

Expand All @@ -47,8 +45,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
if (GenerateMappings.checkXml(finalDocument)) {
String code = null;
try {
code = GenerateMappings.generateMappings(finalDocument, null,
false, "className", "attributeName");
code = GenerateMappings.generateMappings(finalDocument, null, false, "className", "attributeName");
} catch (IOException | BadLocationException ex) {
return;
}
Expand All @@ -61,19 +58,20 @@ public void actionPerformed(@NotNull AnActionEvent e) {
}
} else {
FileChooserDescriptor fileChooserDescriptor =
new FileChooserDescriptor(false, true, false,
false, false, false);
new FileChooserDescriptor(false, true, false, false, false, false);
String separator = FileSystems.getDefault().getSeparator();
List<VirtualFile> virtualFiles = Arrays.stream(ProjectRootManager.getInstance(e.getProject())
.getContentSourceRoots()).filter(
x -> (x.toNioPath().normalize().toString().replace(separator, ".")
.contains("src.main.java"))
).collect(Collectors.toList());
List<VirtualFile> virtualFiles = Arrays.stream(
ProjectRootManager.getInstance(e.getProject()).getContentSourceRoots())
.filter(x -> (x.toNioPath()
.normalize()
.toString()
.replace(separator, ".")
.contains("src.main.java")))
.collect(Collectors.toList());
fileChooserDescriptor.setRoots(virtualFiles);
FileChooser.chooseFile(fileChooserDescriptor, e.getProject(), null, consumer -> {
JTextPanes(consumer.toNioPath().normalize().toString(), finalDocument);
}
);
JTextPanes(consumer.toNioPath().normalize().toString(), finalDocument);
});
}
} catch (RuntimeException ex) {
return;
Expand Down Expand Up @@ -102,7 +100,6 @@ public static void getJTextPlane(String code) throws BadLocationException {
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
frame.setLocationRelativeTo(null);
frame.setVisible(true);

}

void JTextPanes(String path, Document finalDocument) {
Expand All @@ -112,7 +109,7 @@ void JTextPanes(String path, Document finalDocument) {

GridBagConstraints constraints = new GridBagConstraints();
constraints.anchor = GridBagConstraints.WEST;
constraints.insets = JBUI.insets(5);//new Insets(10, 10, 10, 10)
constraints.insets = JBUI.insets(5); // new Insets(10, 10, 10, 10)

constraints.gridx = 0;
constraints.gridy = 0;
Expand Down Expand Up @@ -145,8 +142,7 @@ void JTextPanes(String path, Document finalDocument) {
JLabel label3 = new JLabel(path);
panel.add(label3, constraints);

JOptionPane.showConfirmDialog(null, panel, "Input Dialog",
JOptionPane.OK_CANCEL_OPTION);
JOptionPane.showConfirmDialog(null, panel, "Input Dialog", JOptionPane.OK_CANCEL_OPTION);
String className = Objects.requireNonNullElse(textField.getText(), "ClassName");
boolean isSelected = checkBox.isSelected();
String attributeName = Utilities.GetVariableNameFromClassName(className);
Expand All @@ -155,8 +151,7 @@ void JTextPanes(String path, Document finalDocument) {
if (isSelected) {
GenerateMappings.generateMappings(finalDocument, path, true, className, attributeName);
} else {
String code = GenerateMappings.generateMappings(finalDocument, path,
false, className, attributeName);
String code = GenerateMappings.generateMappings(finalDocument, path, false, className, attributeName);
if (code != null) {
getJTextPlane(code);
}
Expand All @@ -165,8 +160,5 @@ void JTextPanes(String path, Document finalDocument) {
Messages.showMessageDialog(String.valueOf(ex), "ERROR", Messages.getErrorIcon());
return;
}

}


}
Loading

0 comments on commit be7c9cb

Please sign in to comment.