Skip to content

Commit

Permalink
Add README.md, change plugin id and change package structure
Browse files Browse the repository at this point in the history
  • Loading branch information
nailujx86 committed May 28, 2024
1 parent 2caf5bf commit eb99824
Show file tree
Hide file tree
Showing 28 changed files with 224 additions and 173 deletions.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Autoconfig for IntelliJ

Autoconfig is an extension for IntelliJ IDEA which allows you to persist and share project specific IDE-settings outside the `workspace.xml`-file.

## Goal

Several user specific IDE settings are stored for each project in the VCS-ignored-`workspace.xml`-file. This is a good thing, but it can be cumbersome to configure your IDE differently for each project. Some IDE settings that might want to be shared across users:

- Format on Save
- Custom Plugin Repositories
- Compiler Settings
- Maven Importing Settings

Autoconfig helps you with sharing settings across multiple users by allowing you to configure settings in a separate file which can be checked in into your version control. This lessens the need of project specific instructions on how to configure your IDE for working on a project, and it ensures that all users share the same settings.

## How to use

1. Go to `Tools -> Autoconfig -> Create Autoconfig File`
2. Select the type of autoconfig you want to create
3. Create an Autoconfig file for your project
4. Restart your IDE
Autoconfig automatically configures your IDE on restart

## Available settings

See the available settings configurable by Autoconfig in: [schemas](src/main/resources/schema)

## How to contribute

See [CONTRIBUTING.md](CONTRIBUTING.md)
22 changes: 17 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {

allprojects {

group 'de.gebit.intellij.autoconfig'
group 'de.gebit.plugins.autoconfig'

ext {
lombokVersion = '1.18.30'
Expand All @@ -16,11 +16,22 @@ allprojects {
javaxPersistenceVersion = '2.2'
jUnitJupiterVersion = '5.10.1'
intellijType = 'IC' // IC: Community Edition, IU: Ultimate Edition.
intellijVersion = '2024.1' // https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellijSinceBuild = '232.1'
intellijVersion = '2023.2' // https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellijSinceBuild = '232.10300.40'
}
}

patchPluginXml {
sinceBuild = "232.1"
untilBuild = "241.*"
}

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

repositories {
mavenCentral()
}
Expand All @@ -31,7 +42,7 @@ ext.groovyVersion = "3.0.19"
intellij {
// Available IDE versions: https://www.jetbrains.com/intellij-repository/releases and https://www.jetbrains.com/intellij-repository/snapshots
version = System.getenv().getOrDefault("IJ_VERSION",
"2024.1"
"2023.2"
)
pluginName = "AutoConfigPlugin"
downloadSources = true
Expand All @@ -53,6 +64,7 @@ dependencies {
implementation 'javax.validation:validation-api:1.1.0.CR2'
implementation 'jakarta.validation:jakarta.validation-api:3.0.0'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.17.1'
compileOnly("org.projectlombok:lombok:${lombokVersion}")
testCompileOnly("org.projectlombok:lombok:${lombokVersion}")
annotationProcessor("org.projectlombok:lombok:${lombokVersion}")
Expand All @@ -70,7 +82,7 @@ jsonSchema2Pojo {

// Package name used for generated Java classes (for types where a fully qualified name has not
// been supplied in the schema using the 'javaType' property).
targetPackage = 'de.gebit.intellij.autoconfig.model'
targetPackage = 'de.gebit.plugins.autoconfig.model'

// Whether to allow 'additional' properties to be supported in classes by adding a map to
// hold these. This is true by default, meaning that the schema rule 'additionalProperties'
Expand Down
51 changes: 0 additions & 51 deletions src/main/java/de/gebit/intellij/autoconfig/UpdateHandler.java

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Berlin, Duesseldorf, Stuttgart, Leipzig (Germany)
// All rights reserved.

package de.gebit.intellij.autoconfig;
package de.gebit.plugins.autoconfig;

import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.extensions.ExtensionPointName;
Expand All @@ -22,7 +22,7 @@
import java.util.List;
import java.util.Optional;

import static de.gebit.intellij.autoconfig.util.Notifications.showInfo;
import static de.gebit.plugins.autoconfig.util.Notifications.showInfo;

/**
* Entry point for the opening of a project. The yaml configuration file is read here, the resulting configuration options object is passed to the
Expand All @@ -32,7 +32,7 @@ public class AutoconfigStartup implements ProjectActivity {
private static final com.intellij.openapi.diagnostic.Logger LOG = Logger.getInstance(AutoconfigStartup.class);

public static final ExtensionPointName<UpdateHandler<?>>
EP_NAME = ExtensionPointName.create("de.gebit.intellij.autoconfig.configurationUpdater");
EP_NAME = ExtensionPointName.create("de.gebit.plugins.autoconfig.configurationUpdater");

@Nullable
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
// Berlin, Duesseldorf, Stuttgart, Leipzig (Germany)
// All rights reserved.

package de.gebit.intellij.autoconfig;
package de.gebit.plugins.autoconfig;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.components.Service;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import de.gebit.intellij.autoconfig.util.Notifications;
import de.gebit.plugins.autoconfig.util.Notifications;

import java.io.IOException;
import java.util.HashMap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,21 @@
// Berlin, Duesseldorf, Stuttgart, Leipzig (Germany)
// All rights reserved.

package de.gebit.intellij.autoconfig;
package de.gebit.plugins.autoconfig;

import com.intellij.codeInsight.actions.onSave.FormatOnSaveOptionsBase;
import com.intellij.openapi.fileTypes.FileType;
import de.gebit.intellij.autoconfig.state.TransientPluginState;
import de.gebit.intellij.autoconfig.state.TransientPluginStateService;
import de.gebit.plugins.autoconfig.state.TransientPluginState;
import de.gebit.plugins.autoconfig.state.TransientPluginStateService;
import org.jetbrains.annotations.NotNull;

import java.util.Collection;
import java.util.Collections;
import java.util.function.Function;

/**
* Supplier for default file formats that should be formatted or used for optimization of imports.
* Supplier for default file formats that should be formatted or used for optimization of imports. This only works when no manual state is persisted
* in the users workspace.xml.
*/
public class FormatOnSaveOptionsDefaultsProvider implements FormatOnSaveOptionsBase.DefaultsProvider {

Expand Down
57 changes: 57 additions & 0 deletions src/main/java/de/gebit/plugins/autoconfig/UpdateHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
//
// UpdateHandler.java
//
// Copyright (C) 2024
// GEBIT Solutions GmbH,
// Berlin, Duesseldorf, Stuttgart, Leipzig (Germany)
// All rights reserved.

package de.gebit.plugins.autoconfig;

import com.intellij.openapi.project.Project;

import java.util.List;

/**
* Extension point for used to supply configuration update handlers.
*/
public interface UpdateHandler<T> {

/**
* Provide the file name that is expected to contain the extensions' configuration.
*
* @return the file name that is expected to contain the extensions' configuration
*/
String getFileName();

/**
* The json schema containing/providing the information on how to write the configuration file.
*
* @return json schema containing/providing the information on how to write the configuration file
*/
String getJsonSchema();

/**
* The updater name is used for logging purposes and as a name for the json schema displayed in IntelliJ status bar.
*
* @return the name of this updater
*/
String getUpdaterName();

/**
* The configuration object class used to read/deserialize the configuration file.
*
* @return configuration object class used to read/deserialize the configuration file
*/
Class<T> getConfigurationClass();

/**
* The implementation of the configuration updates. A configuration update object is supplied containing the information gathered from the yaml
* file.
*
* @param configuration the configuration object used for this update handler
* @param project the project that will receive the configuration updates in case they can be applied
* @return list of configuration parts that have been updated
*/
List<String> updateConfiguration(T configuration, Project project);
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package de.gebit.intellij.autoconfig.actions;
package de.gebit.plugins.autoconfig.actions;

import com.intellij.ide.IdeView;
import com.intellij.ide.actions.CreateInDirectoryActionBase;
Expand All @@ -15,8 +15,8 @@
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDocumentManager;
import com.intellij.psi.PsiFile;
import de.gebit.intellij.autoconfig.UpdateHandler;
import de.gebit.intellij.autoconfig.create.CreateAutoconfigFileDialog;
import de.gebit.plugins.autoconfig.UpdateHandler;
import de.gebit.plugins.autoconfig.create.CreateAutoconfigFileDialog;
import org.jetbrains.annotations.NotNull;

import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package de.gebit.intellij.autoconfig.actions;
package de.gebit.plugins.autoconfig.actions;

import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAwareAction;
import com.intellij.openapi.project.Project;
import de.gebit.intellij.autoconfig.AutoconfigStartup;
import de.gebit.intellij.autoconfig.ConfigurationLoaderService;
import de.gebit.plugins.autoconfig.AutoconfigStartup;
import de.gebit.plugins.autoconfig.ConfigurationLoaderService;
import org.jetbrains.annotations.NotNull;

/**
Expand All @@ -17,7 +17,7 @@ public void actionPerformed(@NotNull AnActionEvent e) {
if (project == null) {
return;
}

ConfigurationLoaderService configurationLoaderService = project.getService(ConfigurationLoaderService.class);
if (configurationLoaderService != null) {
configurationLoaderService.resetConfigurationCache();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package de.gebit.intellij.autoconfig.create;
package de.gebit.plugins.autoconfig.create;

import com.intellij.openapi.ui.DialogWrapper;
import de.gebit.intellij.autoconfig.AutoconfigStartup;
import de.gebit.intellij.autoconfig.UpdateHandler;
import de.gebit.plugins.autoconfig.AutoconfigStartup;
import de.gebit.plugins.autoconfig.UpdateHandler;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.gebit.intellij.autoconfig.create.CreateAutoconfigFileForm">
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="de.gebit.plugins.autoconfig.create.CreateAutoconfigFileForm">
<grid id="27dc6" binding="form" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package de.gebit.intellij.autoconfig.create;
package de.gebit.plugins.autoconfig.create;

import com.intellij.uiDesigner.core.GridConstraints;
import com.intellij.uiDesigner.core.GridLayoutManager;
import com.intellij.uiDesigner.core.Spacer;
import de.gebit.intellij.autoconfig.UpdateHandler;
import de.gebit.plugins.autoconfig.UpdateHandler;
import lombok.Getter;

import javax.swing.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Berlin, Duesseldorf, Stuttgart, Leipzig (Germany)
// All rights reserved.

package de.gebit.intellij.autoconfig.handlers;
package de.gebit.plugins.autoconfig.handlers;

import java.util.List;
import java.util.function.Consumer;
Expand Down
Loading

0 comments on commit eb99824

Please sign in to comment.