Skip to content

Commit 18b4711

Browse files
committed
More work on build to JARJAR ASM
1 parent 3572346 commit 18b4711

File tree

280 files changed

+328
-181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

280 files changed

+328
-181
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ build/
55
classes/
66
out/
77
*.db
8-
*.log
8+
*.log
9+
*.iml

aop/build.gradle

+8-16
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import org.anarres.gradle.plugin.jarjar.JarjarTask
2-
32
dependencies {
43
compile project(":inject")
54
}
65

6+
77
def targetDir = new File(project.buildDir, "jarjar")
88
def targetFile = new File(targetDir, "asm.jar")
99
def jarjarTask = task("jarjarTask", type: JarjarTask) {
@@ -12,24 +12,16 @@ def jarjarTask = task("jarjarTask", type: JarjarTask) {
1212
destinationDir = targetDir
1313
destinationName = targetFile.name
1414
}
15-
jarjarTask.inputs.files(jar.outputs)
16-
jarjarTask.outputs.files(targetFile)
1715

1816
def jarjarOutputs = task("jarjarOutputs").doLast {
19-
def jar = jar.outputs.files.first()
20-
2117
copy {
22-
from(targetFile).into(jar.parentFile)
23-
rename { String fileName ->
24-
jar.name
25-
}
18+
from zipTree(jarjarTask.outputs.files.first())
19+
into(targetDir)
2620
}
27-
delete(targetDir)
21+
delete(jarjarTask.outputs.files)
2822
}
2923
jarjarOutputs.dependsOn(jarjarTask)
30-
jarjarOutputs.inputs.files(targetFile)
31-
jarjarOutputs.outputs.files(jar.outputs)
32-
33-
tasks.withType(AbstractPublishToMaven) {
34-
it.finalizedBy(jarjarOutputs)
35-
}
24+
task("rejar", type:Jar, dependsOn: jarjarOutputs) {
25+
from(targetDir)
26+
archiveName = "rejar.jar"
27+
}

ast/build.gradle

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@ configurations.all {
22
it.exclude(group:"org.slf4j",module:"jcl-over-slf4j")
33
}
44
dependencies {
5-
compile project(":inject")
5+
compile project(":core")
6+
compile group: 'javax.inject', name: 'javax.inject', version: '1'
67

8+
compile project(":inject")
9+
compile "org.codehaus.groovy:groovy:$groovyVersion"
710
compileOnly project(":aop")
811
compileOnly "org.ow2.asm:asm:$asmVersion"
912
compileOnly "org.ow2.asm:asm-commons:$asmVersion"

build.gradle

+24-23
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ subprojects { subproject ->
2929
version project.projectVersion
3030

3131
ext {
32+
includePublication = true
3233
userOrg = "grails"
3334
isGrailsPlugin = false
3435
isConfiguration = subproject.name.startsWith('configurations')
@@ -52,11 +53,12 @@ subprojects { subproject ->
5253
// apply plugin:"org.grails.grails-web"
5354
}
5455
else {
55-
apply from:"${commonBuild}/common-project-nogroovydoc.gradle"
56+
apply plugin:"groovy"
57+
apply plugin:"java"
5658
sourceCompatibility = '1.8'
5759
targetCompatibility = '1.8'
5860
if(!subproject.name.contains('test-suite')) {
59-
apply from:"${commonBuild}/common-publishing.gradle"
61+
apply from:"${rootProject.rootDir}/gradle/publishing.gradle"
6062
}
6163
}
6264

@@ -67,36 +69,35 @@ subprojects { subproject ->
6769
}
6870
}
6971

72+
configurations {
73+
documentation
74+
all {
75+
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
76+
String group = details.requested.group
77+
if(group == 'org.codehaus.groovy') {
78+
details.useVersion(groovyVersion)
79+
}
80+
}
81+
}
82+
}
83+
7084
dependencies {
85+
compile "org.slf4j:slf4j-api:$slf4jVersion"
86+
testCompile "org.codehaus.groovy:groovy:$groovyVersion"
87+
testCompile("org.spockframework:spock-core:${spockVersion}") {
88+
exclude module:'groovy-all'
89+
}
90+
testCompile "cglib:cglib-nodep:2.2.2"
91+
testCompile "org.objenesis:objenesis:1.4"
92+
7193
testRuntime "ch.qos.logback:logback-classic:1.2.3"
7294
compileOnly 'org.ow2.asm:asm:5.2'
7395
compileOnly 'org.ow2.asm:asm-commons:5.2'
7496

7597
testCompile "org.ow2.asm:asm:$asmVersion"
7698
testCompile "org.ow2.asm:asm-commons:$asmVersion"
77-
7899
}
79100
}
80101

81102
apply from:"${commonBuild}/common-docs.gradle"
82103

83-
// IDEA 2017.2 made a breaking change with IDE build output vs gradle build output
84-
// [see https://youtrack.jetbrains.com/issue/IDEA-175172]
85-
// the problem here is the gradle build uses <module-dir>/build/classes/main
86-
// while IDEA uses <module-dir>/out/production/..
87-
// As a result, compiling ast or java-inject module and using the IDEA test runner fails because the
88-
// generated bean classes for injection are in <module-dir>/build, not <module-dir>/out
89-
allprojects {
90-
apply plugin: 'idea'
91-
idea {
92-
module {
93-
outputDir file('build/classes/main')
94-
testOutputDir file('build/classes/test')
95-
}
96-
}
97-
if(project.convention.findPlugin(JavaPluginConvention)) {
98-
// Change the output directory for the main and test source sets back to the old path
99-
sourceSets.main.output.classesDir = new File(buildDir, "classes/main")
100-
sourceSets.test.output.classesDir = new File(buildDir, "classes/test")
101-
}
102-
}

configurations/hibernate-gorm/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
dependencies {
2+
compile "org.codehaus.groovy:groovy:$groovyVersion"
23
compileOnly project(":ast")
34
compile project(":inject")
45
compile project(":spring")

configurations/hibernate-validator/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
dependencies {
2+
compile "org.codehaus.groovy:groovy:$groovyVersion"
23
compile project(":ast")
34
compile 'org.hibernate:hibernate-validator:5.4.1.Final'
45
compileOnly 'org.glassfish.web:el-impl:2.2.1-b05'

core/build.gradle

+27-6
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,47 @@ def asmjar = project.fileTree('src/jarjar')
1818

1919
def targetDir = new File(project.buildDir, "jarjar")
2020
def targetFile = new File(targetDir, "asm.jar")
21-
def jarjarTask = task("jarjarTask", type: JarjarTask) {
21+
def asmjarjarTask = task("asmjarjarTask", type: JarjarTask) {
2222
from(asmjar)
2323
classRename "org.objectweb.asm.**", "org.particleframework.asm.@1"
2424
destinationDir = targetDir
2525
destinationName = targetFile.name
2626
}
27-
jarjarTask.inputs.files(asmjar)
28-
jarjarTask.outputs.files(targetDir)
27+
asmjarjarTask.inputs.files(asmjar)
28+
asmjarjarTask.outputs.files(targetDir)
2929

30-
def jarjarOutput = task("jarjarOutput")
30+
def jarjarOutput = task("asmjarjarOutput")
3131
jarjarOutput.doLast {
3232
copy {
3333
from(zipTree(targetFile)) {
3434
include "org/particleframework/asm/**"
3535
}
36-
into(new File(project.buildDir, "classes/main"))
36+
into(new File(project.buildDir, "classes/java/main"))
3737
}
3838
}
39-
jarjarOutput.dependsOn(jarjarTask)
39+
jarjarOutput.dependsOn(asmjarjarTask)
4040
classes {
4141
dependsOn(jarjarOutput)
4242
}
4343

44+
45+
def jarjarTask = task("jarjarTask", type: JarjarTask) {
46+
from(project.files(jar.archivePath))
47+
classRename "org.objectweb.asm.**", "org.particleframework.asm.@1"
48+
destinationDir = targetDir
49+
destinationName = targetFile.name
50+
}
51+
jarjarTask.dependsOn(jar)
52+
53+
def jarjarOutputs = task("jarjarOutputs").doLast {
54+
copy {
55+
from zipTree(jarjarTask.destinationPath)
56+
into(targetDir)
57+
}
58+
delete(jarjarTask.destinationPath)
59+
}
60+
jarjarOutputs.dependsOn(jarjarTask)
61+
task("rejar", type:Jar, dependsOn: jarjarOutputs) {
62+
from(targetDir)
63+
archiveName = "rejar.jar"
64+
}

core/src/main/groovy/org/particleframework/core/io/scan/AnnotatedTypeInfoVisitor.java core/src/main/java/org/particleframework/core/io/scan/AnnotatedTypeInfoVisitor.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
*/
1616
package org.particleframework.core.io.scan;
1717

18-
import groovyjarjarasm.asm.AnnotationVisitor;
19-
import groovyjarjarasm.asm.ClassVisitor;
20-
import groovyjarjarasm.asm.Opcodes;
21-
import groovyjarjarasm.asm.Type;
18+
import org.objectweb.asm.AnnotationVisitor;
19+
import org.objectweb.asm.ClassVisitor;
20+
import org.objectweb.asm.Opcodes;
21+
import org.objectweb.asm.Type;
2222
import org.particleframework.core.annotation.AnnotatedTypeInfo;
2323
import org.particleframework.core.reflect.ClassUtils;
2424

core/src/main/groovy/org/particleframework/core/io/scan/AnnotationClassReader.java core/src/main/java/org/particleframework/core/io/scan/AnnotationClassReader.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@
2929
*/
3030
package org.particleframework.core.io.scan;
3131

32+
import org.objectweb.asm.*;
33+
3234
import java.io.IOException;
3335
import java.io.InputStream;
34-
import groovyjarjarasm.asm.*;
3536

3637
/**
3738
* A limited class parser that parses the class-level annotations for each class only.

core/src/main/groovy/org/particleframework/core/io/scan/Attribute.java core/src/main/java/org/particleframework/core/io/scan/Attribute.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929
*/
3030
package org.particleframework.core.io.scan;
3131

32-
import groovyjarjarasm.asm.*;
32+
33+
import org.objectweb.asm.*;
3334

3435
/**
3536
* A non standard class, field, method or code attribute.

core/src/main/groovy/org/particleframework/core/io/scan/Context.java core/src/main/java/org/particleframework/core/io/scan/Context.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,8 @@
3030

3131
package org.particleframework.core.io.scan;
3232

33-
import groovyjarjarasm.asm.*;
3433
/**
35-
* Information about a class being parsed in a {@link ClassReader}.
34+
* Information about a class being parsed in a {@link org.objectweb.asm.ClassReader}.
3635
*
3736
* @author Eric Bruneton
3837
*/
@@ -44,7 +43,7 @@ class Context {
4443
Attribute[] attrs;
4544

4645
/**
47-
* The {@link ClassReader} option flags for the parsing of this class.
46+
* The {@link org.objectweb.asm.ClassReader} option flags for the parsing of this class.
4847
*/
4948
int flags;
5049

core/src/main/groovy/org/particleframework/core/naming/NameUtils.java core/src/main/java/org/particleframework/core/naming/NameUtils.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
*/
1616
package org.particleframework.core.naming;
1717

18-
import org.codehaus.groovy.runtime.MetaClassHelper;
19-
2018
import java.beans.Introspector;
2119
import java.util.Arrays;
20+
import java.util.Locale;
2221
import java.util.stream.Collectors;
2322

2423
/**
@@ -76,7 +75,14 @@ public static String trimSuffix(String string, String... suffixes) {
7675
* @return The class name
7776
*/
7877
public static String capitalize(String name) {
79-
return MetaClassHelper.capitalize(name);
78+
final String rest = name.substring(1);
79+
80+
// Funky rule so that names like 'pNAME' will still work.
81+
if (Character.isLowerCase(name.charAt(0)) && (rest.length() > 0) && Character.isUpperCase(rest.charAt(0))) {
82+
return name;
83+
}
84+
85+
return name.substring(0, 1).toUpperCase(Locale.ENGLISH) + rest;
8086
}
8187

8288

core/src/main/groovy/org/particleframework/core/naming/conventions/TypeConvention.java core/src/main/java/org/particleframework/core/naming/conventions/TypeConvention.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public enum TypeConvention {
3939
}
4040

4141
/**
42-
* <p>Returns the property name equivalent for this convention for the given class. Eg. BookController -> book</p>
42+
* <p>Returns the property name equivalent for this convention for the given class. Eg. BookController -&gt; book</p>
4343
* @param type The type
4444
* @return The property name equivalent
4545
*/
@@ -48,7 +48,7 @@ public String asPropertyName(Class type) {
4848
}
4949

5050
/**
51-
* <p>Returns the hyphenated equivalent for this convention for the given class. Eg. BookShopController -> book-shop</p>
51+
* <p>Returns the hyphenated equivalent for this convention for the given class. Eg. BookShopController -&gt; book-shop</p>
5252
* @param type The type
5353
* @return The property name equivalent
5454
*/

examples/simple-groovy/build.gradle

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apply plugin:"groovy"
2+
apply plugin: 'application'
3+
mainClassName = "example.Application"
4+
applicationDefaultJvmArgs = ["-verbose"]
5+
repositories {
6+
mavenLocal()
7+
mavenCentral()
8+
}
9+
dependencies {
10+
Properties props = new Properties()
11+
new File("../../gradle.properties").withReader { props.load(it) }
12+
compileOnly "org.particleframework:ast:${props.projectVersion}"
13+
compile "org.codehaus.groovy:groovy:$props.groovyVersion"
14+
compile "org.particleframework:runtime-netty:${props.projectVersion}"
15+
runtime "ch.qos.logback:logback-classic:1.2.3"
16+
}

0 commit comments

Comments
 (0)