-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Applied common Spotless Eclipse framework to CDT (#238)
Applied common Spotless Eclipse framework to CDT
- Loading branch information
Showing
9 changed files
with
75 additions
and
232 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,28 @@ | ||
plugins { | ||
// bintray uploading | ||
id 'com.jfrog.bintray' version '1.3.1' | ||
// p2 dependencies | ||
id 'com.diffplug.gradle.p2.asmaven' version '3.9.0' | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
maven { url 'https://plugins.gradle.org/m2/' } | ||
} | ||
|
||
apply plugin: 'java' | ||
sourceCompatibility = VER_JAVA | ||
targetCompatibility = VER_JAVA | ||
|
||
import java.io.File | ||
|
||
// The dependencies to pull from CDT's p2 repositories | ||
def eclipseCdtDeps = [ | ||
'org.eclipse.cdt.core':'+', // CodeFormatter and related | ||
] | ||
|
||
// The dependencies to pull from Eclipse's p2 repositories | ||
def eclipseDeps = [ | ||
'org.eclipse.core.jobs':'+', // Required by CDT ParserUtil | ||
'org.eclipse.core.resources':'+', | ||
'org.eclipse.core.runtime':'+', // Provides central logging and plugin interface | ||
'org.eclipse.equinox.common':'+', // Provides runtime status used during exception reporting | ||
'org.eclipse.jface':'+', // PreferenceStore for creating preferences from properties | ||
'org.eclipse.text':'+', // Provides Document data structure for formatter | ||
'org.eclipse.osgi':'+', // CCorePlugin requires OSGI bundle interfaces (but not effectively used) | ||
'org.eclipse.osgi.services':'+', | ||
] | ||
ext { | ||
developers = [ | ||
fvgh: [ name: 'Frank Vennemeyer', email: '[email protected]' ], | ||
] | ||
|
||
p2Repository = "http://download.eclipse.org/tools/cdt/releases/${VER_ECLIPSE_CDT}" | ||
|
||
p2Dependencies = [ | ||
'org.eclipse.cdt.core':'+', // CodeFormatter and related | ||
] | ||
|
||
// build a maven repo in our build folder containing these artifacts | ||
p2AsMaven { | ||
group 'p2', { | ||
repoEclipse cdt_VER_ECLIPSE | ||
eclipseDeps.keySet.each { p2.addIU(it) } | ||
eclipseDeps.keySet.each { p2.addIU(it + '.source') } | ||
repo "http://download.eclipse.org/tools/cdt/releases/${cdt_VER_ECLIPSE_CDT}" | ||
eclipseCdtDeps.keySet.each { p2.addIU(it) } | ||
eclipseCdtDeps.keySet.each { p2.addIU(it + '.source') } | ||
} | ||
} | ||
|
||
configurations | ||
{ | ||
embeddedJars // JARs (Eclipse and WTP) the fat-jar is based uppon | ||
embeddedSource // Source for Eclipse JARS (GrEclipse provides no source packages) | ||
compile.extendsFrom(embeddedJars) | ||
} | ||
apply from: rootProject.file('../gradle/p2-fat-jar-setup.gradle') | ||
apply from: rootProject.file('../gradle/java-publish.gradle') | ||
|
||
|
||
dependencies { | ||
// Add the Eclipse and Eclipse-WTP jars to the embedded configuration. | ||
eclipseDeps.each { groupArtifact, version -> | ||
embeddedJars "p2:${groupArtifact}:${version}" | ||
embeddedSource "p2:${groupArtifact}:${version}:sources" | ||
} | ||
eclipseCdtDeps.each { groupArtifact, version -> | ||
embeddedJars "p2:${groupArtifact}:${version}" | ||
embeddedSource "p2:${groupArtifact}:${version}:sources" | ||
compile "com.diffplug.spotless:spotless-eclipse-base:${VER_SPOTLESS_ECLISPE_BASE}" | ||
// Provides text partitioners for formatters | ||
compile ("org.eclipse.platform:org.eclipse.jface.text:${VER_ECLISPE_JFACE}") { | ||
exclude group: 'org.eclipse.platform', module: 'org.eclipse.swt' | ||
} | ||
|
||
testCompile "junit:junit:${cdt_VER_JUNIT}" | ||
} | ||
|
||
jar { | ||
// this embeds the eclipse jars into our "fat jar" | ||
from { | ||
configurations.embeddedJars.collect{ it.isDirectory() ? it : zipTree(it) } | ||
} | ||
// the eclipse jars are signed, and our fat jar breaks the signatures | ||
// so we've got to be sure to filter out the signatures | ||
exclude 'META-INF/*.RSA' | ||
exclude 'META-INF/*.SF' | ||
} | ||
|
||
////////// | ||
// Test // | ||
|
@@ -85,133 +31,3 @@ sourceSets { | |
// Use JAR file with all resources for Eclipse-XML integration-tests | ||
test.runtimeClasspath = jar.outputs.files + sourceSets.test.output + sourceSets.test.compileClasspath | ||
} | ||
|
||
///////// | ||
// IDE // | ||
///////// | ||
|
||
apply plugin: 'eclipse' | ||
|
||
eclipse { | ||
classpath { | ||
downloadSources true | ||
downloadJavadoc true | ||
} | ||
} | ||
|
||
// always create fresh projects | ||
tasks.eclipse.dependsOn(cleanEclipse) | ||
|
||
//////////////// | ||
// Publishing // | ||
//////////////// | ||
apply plugin: 'maven-publish' | ||
|
||
task sourcesJar(type: Jar) { | ||
classifier = 'sources' | ||
from sourceSets.main.allJava | ||
} | ||
|
||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
classifier = 'javadoc' | ||
from javadoc.destinationDir | ||
} | ||
|
||
def isSnapshot = cdt_version.endsWith('-SNAPSHOT') | ||
// pulls the credentials from either the environment variable or gradle.properties | ||
def cred = { | ||
if (System.env[it] != null) { | ||
return System.env[it] | ||
} else if (project.hasProperty(it)) { | ||
return project[it] | ||
} else { | ||
return 'unknown_' + it | ||
} | ||
} | ||
|
||
model { | ||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
|
||
groupId project.cdt_group | ||
artifactId project.cdt_artifactId | ||
version project.cdt_version | ||
from components.java | ||
|
||
pom.withXml { | ||
|
||
// add MavenCentral requirements to the POM | ||
asNode().children().last() + { | ||
resolveStrategy = Closure.DELEGATE_FIRST | ||
name project.cdt_artifactId | ||
description project.cdt_description | ||
url "https://github.com/${project.cdt_org}/${project.name}" | ||
scm { | ||
url "https://github.com/${project.cdt_org}/${project.name}" | ||
connection "scm:git:git://github.com/${project.cdt_org}/${project.name}" | ||
developerConnection "scm:git:ssh:[email protected]/${project.cdt_org}/${project.name}" | ||
} | ||
licenses { | ||
license { | ||
name 'Eclipse Public License - v 1.0' | ||
url 'https://www.eclipse.org/legal/epl-v10.html' | ||
distribution 'repo' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id 'fvgh' | ||
name 'Frank Vennemeyer' | ||
email '[email protected]' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
if (isSnapshot) { | ||
// upload snapshots to oss.sonatype.org | ||
repositories { | ||
maven { | ||
url = 'https://oss.sonatype.org/content/repositories/snapshots' | ||
credentials { | ||
username = cred('nexus_user') | ||
password = cred('nexus_pass') | ||
} | ||
} } | ||
} | ||
} | ||
} | ||
|
||
if (!isSnapshot) { | ||
// upload releases to bintray and then mavenCentral | ||
bintray { | ||
user = cred('bintray_user') | ||
key = cred('bintray_pass') | ||
publications = [ | ||
'mavenJava' | ||
] | ||
publish = true | ||
pkg { | ||
repo = 'opensource' | ||
name = project.cdt_artifactId | ||
userOrg = project.cdt_org | ||
version { | ||
name = project.cdt_version | ||
mavenCentralSync { | ||
user = cred('nexus_user') | ||
password = cred('nexus_pass') | ||
} | ||
} | ||
} | ||
} | ||
|
||
publish.dependsOn(bintrayUpload) | ||
bintrayUpload.dependsOn([ | ||
'generatePomFileForMavenJavaPublication', | ||
jar, | ||
sourcesJar, | ||
javadocJar | ||
]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
# Mayor/Minor versions are in line with the one of the Eclipse C/C++ IDE version. | ||
# Patch version is an incremental counter for the Spotless plugin. | ||
cdt_version=9.4.0-SNAPSHOT | ||
cdt_artifactId=spotless-ext-eclipse-cdt | ||
cdt_description=Eclipse's CDT C/C++ formatter bundled for Spotless | ||
VER_JAVA=1.8 | ||
# Versions correspond to the Eclipse-CDT version used for the fat-JAR. | ||
# See https://www.eclipse.org/cdt/ for further information about Eclipse-CDT versions. | ||
# Patch version can be incremented independently for backward compatible patches of this library. | ||
ext_version=9.4.3 | ||
ext_artifactId=spotless-eclipse-cdt | ||
ext_description=Eclipse's CDT C/C++ formatter bundled for Spotless | ||
ext_org=diffplug | ||
ext_group=com.diffplug.spotless | ||
|
||
cdt_org=diffplug | ||
cdt_group=com.diffplug.spotless | ||
# Build requirements | ||
ext_VER_JAVA=1.8 | ||
|
||
# Compile dependencies | ||
cdt_VER_ECLIPSE=4.7.2 | ||
cdt_VER_ECLIPSE_CDT=9.4 | ||
|
||
# Test | ||
cdt_VER_JUNIT=4.12 | ||
VER_ECLIPSE_CDT=9.4 | ||
VER_SPOTLESS_ECLISPE_BASE=3.+ | ||
VER_ECLISPE_JFACE=[3.12.0,4.0.0[ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
_ext/eclipse-cdt/src/main/java/com/diffplug/spotless/extra/eclipse/cdt/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Copyright 2016 DiffPlug | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/** Eclipse CDT based Spotless formatter */ | ||
@ParametersAreNonnullByDefault | ||
package com.diffplug.spotless.extra.eclipse.cdt; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters