-
Notifications
You must be signed in to change notification settings - Fork 460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration to Eclipse formatter hosted on Maven Central #226
Comments
The official artifacts do exist now, but it's a little complicated. The mapping from "I want version 4.7.2" to the collection of jars that make up 4.7.2 is fairly complex. Coincidentally, I merged support for this mapping into the goomph plugin today. I'd be happy to merge a PR for this into Spotless, but it will be quite a lot of work, and I'm not sure what the benefit would be. The shim code between Spotless and Eclipse is fairly complicated, so it would be hard to write in the reflection style that we normally use. |
Hmm, okay. I don't think I'll be able to raise a PR myself in the foreseeable future, as my time and energy is a bit limited nowadays due to job searching, and also because admittedly my knowledge of the guts of Eclipse is... very minimal, to say the least. :) Considering this, would it be best if I closed this issue for now to keep the issue count down? Or would you say that it's important enough to keep open? |
Let's close it. If anybody wants to pick it up they can reopen it. |
Will be fixed as part of eclipse-base provision and update of current Eclipse based formatters. |
I am afraid I am not quite sure whether I have the same idea/problem in mind when I assigned the issue to myself. As you can see in #234 , I am using for the Eclipse core already the versions provided are Maven Central.
So my idea was basically that the This leaves me with following problems:
Any thoughts? Otherwise I would propose the following way forward:
|
As a user interface, I think it's important to be FWIW, the latest version of Goomph has this function. You pass it |
For the user interface you are right for JDT, since it is still more bound to the Eclipse project than any other language extension. I have my doubts that the approach would make sense for CDT users. There the versioning is completely decoupled from the Eclipse version. Anyhow, the user interface and version of the Spotless Eclipse extension should be different issues. With the new Spotless JDT, we have nothing else than glue code, which will not change between 4.7.2 and 4.8.x. So it is somehow confusing to call the Spotless JDT version 4.7... if it actually also will support higher and lower versions. So there is no technical binding between code version and Eclipse version, and if hopefully the same code still works with Eclipse 4.9, we will not count up the Spotless JDT version. With WTP you will find that the formatter relevant code has not changed since 5 years. Furthermore the WTP is a collection of several projects with independent numbers. So also for Spotless extensions using fat JARs there is no fix relation between Eclipse version and the Spotless extension version. Keep in mind that we have no pure fat JARs anymore, the Eclipse core is no always coming from Maven Central. Hence, leaving the user interface aside, I propose that the Spotless JDT, WTP... version should be <x.y.z>, whereas
|
The versioning you propose sounds good to me. |
Leaves the problem that we are reducing the version numbers of existing Maven artifacts (spotless-ext-greclipse, spotless-ext-eclipse-jdt), which I find not acceptable,
|
@nedtwigg Requirements
Implementation (in case the requirements are agreed)
I was thinking of an approach similar to Ruby Gemfile.lock. The Spotless lib-extra will provide for certain Eclipse versions for each Spotless Eclipse formatter dependency version configurations. These can be files (part for the JARs resources). The Maven/Gradle user can also specify its own dependency lock file per formatter. In case the specified lock file does not exist, the Spotless plugin will just resolve the dependencies via the configured M2 repositories and write the lock file. Since the Spotless Eclipse formatter dependency version range is configured to take the latest compatible version, it is likely that the resulting config will work, but as pointed out in §3, this is not ensured. |
This sounds good to me, except I'm hesitant about the "lockfile" part. Yet-another-file-format-for-specifying dependencies. When a formatter already has a file-format (e.g. eclipse('4.7.0') // officially supported eclipse version
eclipseCustom({ // custom unsupported verison
dep('org.eclipse.jdt:jdt:7.8.0')
}) |
For overwriting particular dependencies, I completely agree to provide build script extensions, though I would prefer to make it part of eclipse it self. eclipse('4.7.0') {
configFile 'spotless.eclipseformat.xml'
dep 'org.eclipse.jdt:jdt:7.8.0'
} '4.7.0' refers to a certain certain of a spotless-eclipse-jdt artifact, but also to a file in the Jar resources, containing the 14 transitive dependencies. These transitive dependencies can be overwritten. eclipse('4.7.0') {
configFile 'spotless.eclipseformat.xml' 'spotless.eclipseformat2.xml'
dep 'org.eclipse.jdt:jdt:7.8.0' 'org.eclipse.platform:org.eclipse-core.runtime:3.13.0'
depFile 'spotless.eclipsedeps1.properties' 'spotless.eclipsedeps2.properties'
depNew 'spotless.eclipsedeps.properties'
}
|
But the user won't have to specify all 35. If they specify
I'm fairly skeptical of this. Here's our current approach: spotless/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JavaExtension.java Lines 147 to 176 in e61bc71
The great thing about this is:
More options is not better, it's more for us to document, more for us to test, more for the user to understand. I'm fine with supporting the 5% use-case for cutting-edge users, but the API we provide should just be a |
The user does not have to, but we have to. When you look at the dependencies of
|
I must admit I am not sure what gradle/groovy editors support.
You can now additionally specify an URL instead of |
How about this for an API: public EclipseConfig eclipse() {
return eclipse(EclipseFormatterStep.defaultVersion());
}
public EclipseConfig eclipse(String version) {
return new EclipseConfig().depFile('classpath:org.eclipse.jdt/version.properties')
}
public class EclipseConfig {
private Map<String, String> artifactGroupToVersion;
public EclipseConfig configFile(Object... configFiles) { }
public EclipseConfig dep(String groupArtifactVersion) { ... set artifactGroupToVersion ... }
public EclipseConfig depFile(Object depFile) { ... set artifactGroupToVersion ... }
} |
Sorry, I just don't like these train wracks, they just don't look like gradle. What about this compromise; public EclipseConfig eclipse() {
return eclipse(EclipseFormatterStep.defaultVersion());
}
public EclipseConfig eclipse(String version) {
/*
Code that checks whether version is a an URL (file:/classpath:/https:/...).
Conversion and error handling. To specify an URL here is an undocumented feature.
In case the user specifies unsupported version, the supported once are listed in the error message.
*/
}
private EclipseConfig eclipse(URL defaultDepenencies) {
....
}
public class EclipseConfig {
public EclipseConfig configFile(Object... configFiles) { }
public EclipseConfig dependency(String.... groupArtifactVersions)
} So for the nominal (rare) scenario, where the interested user just specifies one, or at maximum three dependency deviations, the gradle configuration is still readable. |
I think it's a great solution! 👍 |
* Common Spotless Eclipse Framework which can be used by most Spotless Eclipse based formatters. * Added usage information for fat JARs. * Make developers in common java-publish.gradle configurable. * Enhanced framework interfaces. Eclipse core uses plugins not derived from Plugin but BundleActivator. Provided possibility to configure global preferences. Usage of Consumer allows the user to get rid of statics. * Refactored directory structure as discussed in #234 * Refactored directory structure as discussed in #234 * Adpated package names according to previous commit. Applied fixes as requested in #234. Refactored artifact name and version as discussed in #226. * Moved LINE_DELIMITER to SpotlessEclipseFramework * Enhanced error report in case OSGI bundle creation fails. This improves the development of Eclipse formatters. * Applied review proposals. Enhanced BundleController by creating separate class for SimpleBundel (previously called SystemBundle). Added support for plugins offering headless builds. * Allow configuration of snapshot repository for upload. * Added Gradle dependency lock support. Applied changes requested by review (@JLLeitschuh). * Changed "unchecked" warning suppression for Java 10 compliance. * Replaced JavaDoc @see with @code to avoid warnings when referring to implementations in dependencies. * Added missing method implementation (org.eclipse.osgi update from 3.12 to 3.13) * Fixed bintray usage. Plugin-ID for bintray does not work within script (see #1262). Removed model space to allow local publishing of releases. * Finalized version 3.0.0
Published in plugin-gradle 3.14.0 and plugin-maven 1.14.0. |
On reading diffplug/goomph#47, I'm kind of curious to know if there are any plans to migrate away from DiffPlug's spotless-ext-eclipse-jdt version of the Eclipse formatter, to whatever the appropriate, official artifact on Maven Central is (assuming it exists now). :)
The text was updated successfully, but these errors were encountered: