Skip to content

Commit 3211982

Browse files
Added support for Gradle (#3443)
Co-authored-by: badido18 <[email protected]>
1 parent ca8eaee commit 3211982

15 files changed

+522
-2
lines changed

components.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components.json

+5
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,11 @@
544544
"alias": "go-mod",
545545
"owner": "RunDevelopment"
546546
},
547+
"gradle": {
548+
"title": "Gradle",
549+
"require": "clike",
550+
"owner": "zeabdelkhalek-badido18"
551+
},
547552
"graphql": {
548553
"title": "GraphQL",
549554
"optional": "markdown",

components/prism-gradle.js

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
(function (Prism) {
2+
var interpolation = {
3+
pattern: /((?:^|[^\\$])(?:\\{2})*)\$(?:\w+|\{[^{}]*\})/,
4+
lookbehind: true,
5+
inside: {
6+
'interpolation-punctuation': {
7+
pattern: /^\$\{?|\}$/,
8+
alias: 'punctuation',
9+
},
10+
'expression': {
11+
pattern: /[\s\S]+/,
12+
inside: null,
13+
},
14+
},
15+
};
16+
17+
Prism.languages.gradle = Prism.languages.extend('clike', {
18+
'string': {
19+
pattern: /'''(?:[^\\]|\\[\s\S])*?'''|'(?:\\.|[^\\'\r\n])*'/,
20+
greedy: true,
21+
},
22+
'keyword':
23+
/\b(?:apply|def|dependencies|else|if|implementation|import|plugin|plugins|project|repositories|repository|sourceSets|tasks|val)\b/,
24+
'number': /\b(?:0b[01_]+|0x[\da-f_]+(?:\.[\da-f_p\-]+)?|[\d_]+(?:\.[\d_]+)?(?:e[+-]?\d+)?)[glidf]?\b/i,
25+
'operator': {
26+
pattern:
27+
/(^|[^.])(?:~|==?~?|\?[.:]?|\*(?:[.=]|\*=?)?|\.[@&]|\.\.<|\.\.(?!\.)|-[-=>]?|\+[+=]?|!=?|<(?:<=?|=>?)?|>(?:>>?=?|=)?|&[&=]?|\|[|=]?|\/=?|\^=?|%=?)/,
28+
lookbehind: true,
29+
},
30+
'punctuation': /\.+|[{}[\];(),:$]/,
31+
});
32+
33+
Prism.languages.insertBefore('gradle', 'string', {
34+
'shebang': {
35+
pattern: /#!.+/,
36+
alias: 'comment',
37+
greedy: true,
38+
},
39+
'interpolation-string': {
40+
pattern:
41+
/"""(?:[^\\]|\\[\s\S])*?"""|(["/])(?:\\.|(?!\1)[^\\\r\n])*\1|\$\/(?:[^/$]|\$(?:[/$]|(?![/$]))|\/(?!\$))*\/\$/,
42+
greedy: true,
43+
inside: {
44+
'interpolation': interpolation,
45+
'string': /[\s\S]+/,
46+
},
47+
},
48+
});
49+
50+
Prism.languages.insertBefore('gradle', 'punctuation', {
51+
'spock-block': /\b(?:and|cleanup|expect|given|setup|then|when|where):/,
52+
});
53+
54+
Prism.languages.insertBefore('gradle', 'function', {
55+
'annotation': {
56+
pattern: /(^|[^.])@\w+/,
57+
lookbehind: true,
58+
alias: 'punctuation',
59+
},
60+
});
61+
62+
interpolation.inside.expression.inside = Prism.languages.gradle;
63+
}(Prism));

components/prism-gradle.min.js

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/prism-gradle.html

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<h2>Full example</h2>
2+
<pre><code>apply plugin: "java"
3+
apply plugin: "eclipse"
4+
apply plugin: "idea"
5+
6+
group = "com.mycompany.hadoopproject"
7+
version = "1.0"
8+
9+
repositories {
10+
// Standard Maven
11+
mavenCentral()
12+
maven {
13+
url "https://repository.cloudera.com/artifactory/cloudera-repos/"
14+
}
15+
}
16+
17+
// Mimic Maven 'provided' configuration, as suggested in GRADLE-784
18+
configurations {
19+
provided
20+
}
21+
sourceSets {
22+
main {
23+
compileClasspath += configurations.provided
24+
}
25+
}
26+
27+
ext.hadoopVersion = "2.0.0-mr1-cdh4.0.1"
28+
dependencies {
29+
provided "org.apache.hadoop:hadoop-client:${hadoopVersion}"
30+
31+
// Example of adding a specific compile time dependency
32+
compile "com.google.guava:guava:11.0.2"
33+
34+
testCompile "junit:junit:4.8.2"
35+
}
36+
37+
// Java version selection
38+
sourceCompatibility = 1.6
39+
targetCompatibility = 1.6
40+
41+
eclipse {
42+
classpath {
43+
// Ensure Eclipse build output appears in build directory
44+
defaultOutputDir = file("${buildDir}/eclipse-classes")
45+
// Ensure the provided configuration jars are available in Eclipse
46+
plusConfigurations += configurations.provided
47+
}
48+
}
49+
50+
// Emulate Maven shade plugin with a fat jar.
51+
// http://docs.codehaus.org/display/GRADLE/Cookbook#Cookbook-Creatingafatjar
52+
jar {
53+
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
54+
}</code></pre>

plugins/autoloader/prism-autoloader.js

+1
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
"gml": "clike",
5959
"glsl": "c",
6060
"go": "clike",
61+
"gradle": "clike",
6162
"groovy": "clike",
6263
"haml": "ruby",
6364
"handlebars": "markup-templating",

plugins/autoloader/prism-autoloader.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
@BaseScript MyBaseClass baseScript
2+
@DelegatesTo(EmailSpec)
3+
4+
----------------------------------------------------
5+
6+
[
7+
["annotation", "@BaseScript"],
8+
" MyBaseClass baseScript\r\n",
9+
["annotation", "@DelegatesTo"],
10+
["punctuation", "("],
11+
"EmailSpec",
12+
["punctuation", ")"]
13+
]
14+
15+
----------------------------------------------------
16+
17+
Checks for annotations.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
implementation
2+
val tasks dependencies project plugin plugins
3+
repository repositories apply def sourceSets import
4+
if else
5+
----------------------------------------------------
6+
7+
[
8+
["keyword", "implementation"],
9+
10+
["keyword", "val"],
11+
["keyword", "tasks"],
12+
["keyword", "dependencies"],
13+
["keyword", "project"],
14+
["keyword", "plugin"],
15+
["keyword", "plugins"],
16+
17+
["keyword", "repository"],
18+
["keyword", "repositories"],
19+
["keyword", "apply"],
20+
["keyword", "def"],
21+
["keyword", "sourceSets"],
22+
["keyword", "import"],
23+
24+
["keyword", "if"],
25+
["keyword", "else"]
26+
]
27+
28+
----------------------------------------------------
29+
30+
Checks for all keywords.
+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
0b0110
2+
0b0110_1111_0000
3+
0b01G 0b01L 0b01I
4+
0b01D 0b01F
5+
6+
0xBABE
7+
0xBad_Face
8+
0x1.8p1
9+
0xa.fp-2
10+
11+
42_000
12+
3.14_15_9
13+
1.2e3
14+
3E+1
15+
4E-2
16+
42g 42l 42i
17+
42d 42f
18+
19+
----------------------------------------------------
20+
21+
[
22+
["number", "0b0110"],
23+
["number", "0b0110_1111_0000"],
24+
["number", "0b01G"], ["number", "0b01L"], ["number", "0b01I"],
25+
["number", "0b01D"], ["number", "0b01F"],
26+
27+
["number", "0xBABE"],
28+
["number", "0xBad_Face"],
29+
["number", "0x1.8p1"],
30+
["number", "0xa.fp-2"],
31+
32+
["number", "42_000"],
33+
["number", "3.14_15_9"],
34+
["number", "1.2e3"],
35+
["number", "3E+1"],
36+
["number", "4E-2"],
37+
["number", "42g"], ["number", "42l"], ["number", "42i"],
38+
["number", "42d"], ["number", "42f"]
39+
]
40+
41+
----------------------------------------------------
42+
43+
Checks for binary, hexadecimal and decimal numbers.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
~
2+
= == =~ ==~
3+
? ?. ?:
4+
* ** *. *= **=
5+
.@ .&
6+
5..8
7+
5..<8
8+
- -- -= ->
9+
+ ++ +=
10+
! !=
11+
< << <<= <= <=>
12+
> >> >>> >>= >>>= >=
13+
& && &=
14+
| || |=
15+
/
16+
/=
17+
^ ^=
18+
% %=
19+
20+
----------------------------------------------------
21+
22+
[
23+
["operator", "~"],
24+
["operator", "="], ["operator", "=="], ["operator", "=~"], ["operator", "==~"],
25+
["operator", "?"], ["operator", "?."], ["operator", "?:"],
26+
["operator", "*"], ["operator", "**"], ["operator", "*."], ["operator", "*="], ["operator", "**="],
27+
["operator", ".@"], ["operator", ".&"],
28+
["number", "5"], ["operator", ".."], ["number", "8"],
29+
["number", "5"], ["operator", "..<"], ["number", "8"],
30+
["operator", "-"], ["operator", "--"], ["operator", "-="], ["operator", "->"],
31+
["operator", "+"], ["operator", "++"], ["operator", "+="],
32+
["operator", "!"], ["operator", "!="],
33+
["operator", "<"], ["operator", "<<"], ["operator", "<<="], ["operator", "<="], ["operator", "<=>"],
34+
["operator", ">"], ["operator", ">>"], ["operator", ">>>"], ["operator", ">>="], ["operator", ">>>="], ["operator", ">="],
35+
["operator", "&"], ["operator", "&&"], ["operator", "&="],
36+
["operator", "|"], ["operator", "||"], ["operator", "|="],
37+
["operator", "/"],
38+
["operator", "/="],
39+
["operator", "^"], ["operator", "^="],
40+
["operator", "%"], ["operator", "%="]
41+
]
42+
43+
----------------------------------------------------
44+
45+
Checks for all operators.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!foobar
2+
#!/usr/bin/env groovy
3+
4+
----------------------------------------------------
5+
6+
[
7+
["shebang", "#!foobar"],
8+
["shebang", "#!/usr/bin/env groovy"]
9+
]
10+
11+
----------------------------------------------------
12+
13+
Check for shebang comments.

0 commit comments

Comments
 (0)