Skip to content

Commit

Permalink
simplify by only running from Groovy 3 up
Browse files Browse the repository at this point in the history
  • Loading branch information
paulk-asert committed Sep 11, 2024
1 parent dc30537 commit 0ae468c
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,10 @@ class PerformanceTestsExtension {
it.attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements, LibraryElements.JAR))
it.attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))
}
conf.dependencies.add(dependencies.create(v == 'current' ? dependencies.project([path: ':']) : (v.startsWith('4') ? "org.apache.groovy:groovy:$v" : "org.codehaus.groovy:groovy:$v")))
if (!v.startsWith('2.4')) {
conf.dependencies.add(dependencies.create(v == 'current' ? dependencies.project([path: ':groovy-dateutil']) : (v.startsWith('4') ? "org.apache.groovy:groovy-dateutil:$v" : "org.codehaus.groovy:groovy-dateutil:$v")))
conf.dependencies.add(dependencies.create(v == 'current' ? dependencies.project([path: ':groovy-datetime']) : (v.startsWith('4') ? "org.apache.groovy:groovy-datetime:$v" : "org.codehaus.groovy:groovy-datetime:$v")))
conf.dependencies.add(dependencies.create(v.startsWith('current') ? dependencies.project([path: ':']) : "org.apache.groovy:groovy:$v"))
['groovy-dateutil', 'groovy-datetime', 'groovy-ant', 'groovy-swing', 'groovy-sql', 'groovy-xml', 'groovy-templates'].each { m ->
conf.dependencies.add(dependencies.create(v.startsWith('current') ? dependencies.project([path: ":$m"]) : "org.apache.groovy:$m:$v"))
}
conf.dependencies.add(dependencies.create(v == 'current' ? dependencies.project([path: ':groovy-swing']) : (v.startsWith('4') ? "org.apache.groovy:groovy-swing:$v" : "org.codehaus.groovy:groovy-swing:$v")))
conf.dependencies.add(dependencies.create(v == 'current' ? dependencies.project([path: ':groovy-sql']) : (v.startsWith('4') ? "org.apache.groovy:groovy-sql:$v" : "org.codehaus.groovy:groovy-sql:$v")))
conf.dependencies.add(dependencies.create(v == 'current' ? dependencies.project([path: ':groovy-xml']) : (v.startsWith('4') ? "org.apache.groovy:groovy-xml:$v" : "org.codehaus.groovy:groovy-xml:$v")))
conf.dependencies.add(dependencies.create(v == 'current' ? dependencies.project([path: ':groovy-templates']) : (v.startsWith('4') ? "org.apache.groovy:groovy-templates:$v" : "org.codehaus.groovy:groovy-templates:$v")))
[
'org.cyberneko:html:1.9.8',
'commons-net:commons-net:3.11.1',
Expand All @@ -109,8 +104,9 @@ class PerformanceTestsExtension {
'net.sourceforge.expectj:expectj:2.0.7',
'jline:jline:2.14.6',
'prevayler:prevayler:2.02.005',
'xerces:xercesImpl:2.12.2'
].each {conf.dependencies.add(dependencies.create(it)) }
'xerces:xercesImpl:2.12.2',
'hsqldb:hsqldb:1.8.0.10'
].each { conf.dependencies.add(dependencies.create(it)) }
}
def outputFile = layout.buildDirectory.file("compilation-stats-${version}.csv")
def perfTest = tasks.register("performanceTestGroovy${version}", JavaExec) { je ->
Expand Down
5 changes: 1 addition & 4 deletions subprojects/performance/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ plugins {
}

performanceTests {
versions '2.5.20',
'3.0.14',
'4.0.7',
'current'
versions 'current', '3.0.22', '4.0.22'

testFiles project.files("src/files") +
project.files('src/jmh/groovy/org/apache/groovy/bench/Ackermann.groovy') +
Expand Down
5 changes: 4 additions & 1 deletion subprojects/performance/src/files/pleac01.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/

/**
* Refer to pleac.sourceforge.net if wanting accurate comparisons with PERL.
* Original author has included tweaked examples here solely for the purposes
Expand All @@ -24,6 +25,8 @@
* dependencies or for dependencies not in common repos.
*/

import groovy.ant.AntBuilder

// @@PLEAC@@_1.0
//----------------------------------------------------------------------------------
string = '\\n' // two characters, \ and an n
Expand Down Expand Up @@ -419,7 +422,7 @@ assert sanitized == expected
// SendMail.groovy: Send email
// Usage: groovy SendEmail <msgfile>
// script:
class AntBuilder{}

ant = new AntBuilder()
ant.mail(from:'manager@grumpybank.com', tolist:'innocent@poorhouse.com',
encoding:'plain', mailhost:'mail.someserver.com',
Expand Down
5 changes: 4 additions & 1 deletion subprojects/performance/src/files/pleac05_06.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/

/**
* Refer to pleac.sourceforge.net if wanting accurate comparisons with PERL.
* Original author has included tweaked examples here solely for the purposes
Expand All @@ -24,6 +25,8 @@
* dependencies or for dependencies not in common repos.
*/

import groovy.ant.AntBuilder

// @@PLEAC@@_5.0
//----------------------------------------------------------------------------------
// quotes are optional around the key
Expand Down Expand Up @@ -1400,7 +1403,7 @@ println 'Book Publishing <marketing@books.com> (We will spam you)'.replaceAll(si
// inspired by the fact that domain names can contain any foreign character these days
modern = /^.+@[^\.].*\.[a-z]{2,}>?$/

// .Net
// .Net
lenient = /\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/

// a little more checking
Expand Down
3 changes: 3 additions & 0 deletions subprojects/performance/src/files/pleac07_10.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/

/**
* Refer to pleac.sourceforge.net if wanting accurate comparisons with PERL.
* Original author has included tweaked examples here solely for the purposes
Expand All @@ -24,6 +25,8 @@
* dependencies or for dependencies not in common repos.
*/

import groovy.ant.AntBuilder

// @@PLEAC@@_7.0
//----------------------------------------------------------------------------------
//testfile = new File('/usr/local/widgets/data') // unix
Expand Down
12 changes: 5 additions & 7 deletions subprojects/performance/src/files/pleac11_15.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/

/**
* Refer to pleac.sourceforge.net if wanting accurate comparisons with PERL.
* Original author has included tweaked examples here solely for the purposes
Expand All @@ -24,6 +25,9 @@
* dependencies or for dependencies not in common repos.
*/

import org.hsqldb.jdbc.jdbcDataSource
import groovy.swing.SwingBuilder

// @@PLEAC@@_11.0
//----------------------------------------------------------------------------------
// In Groovy, most usages of names are references (there are some special
Expand Down Expand Up @@ -2014,7 +2018,6 @@ def addUsers(store) {
}
}

//def ds = new org.hsqldb.jdbc.jdbcDataSource()
def ds = new jdbcDataSource()
ds.database = 'jdbc:hsqldb:hsql://localhost/mydb'
ds.user = 'sa'
Expand Down Expand Up @@ -2064,11 +2067,9 @@ myEnv.close()
// Here is a more realistic example, copying pbeans -> jdbc
// Creation of pbeans database not strictly needed but shown for completion

class jdbcDataSource {}
//import net.sourceforge.pbeans.*
import groovy.sql.Sql

//ds = new org.hsqldb.jdbc.jdbcDataSource()
ds = new jdbcDataSource()
ds.database = 'jdbc:hsqldb:hsql://localhost/mydb'
ds.user = 'sa'
Expand Down Expand Up @@ -2224,7 +2225,6 @@ myEnv.close()
//----------------------------------------------------------------------------------
// example using pbeans
//import net.sourceforge.pbeans.*
//ds = new org.hsqldb.jdbc.jdbcDataSource()
ds = new jdbcDataSource()
ds.database = 'jdbc:hsqldb:hsql://localhost/mydb'
ds.user = 'sa'
Expand Down Expand Up @@ -2275,7 +2275,6 @@ import groovy.sql.Sql

users = ['20':'Joe Bloggs', '40':'Bill Clinton', '60':'Ben Franklin']

//def source = new org.hsqldb.jdbc.jdbcDataSource()
def source = new jdbcDataSource()
source.database = 'jdbc:hsqldb:mem:PLEAC'
source.user = 'sa'
Expand Down Expand Up @@ -2667,8 +2666,7 @@ command.stop()
//----------------------------------------------------------------------------------
// Methods not shown for the edit menu items, they would be the same as for the
// file menu items.
//import groovy.swing.SwingBuilder
class SwingBuilder{}

def print() {}
def save() {}
frame = new SwingBuilder().frame(title:'Demo') {
Expand Down
10 changes: 7 additions & 3 deletions subprojects/performance/src/files/pleac16_20.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/

/**
* Refer to pleac.sourceforge.net if wanting accurate comparisons with PERL.
* Original author has included tweaked examples here solely for the purposes
Expand All @@ -24,6 +25,9 @@
* dependencies or for dependencies not in common repos.
*/

import org.hsqldb.jdbc.jdbcDataSource
import groovy.ant.AntBuilder

// @@PLEAC@@_16.1
//----------------------------------------------------------------------------------
output = "program args".execute().text
Expand Down Expand Up @@ -832,6 +836,7 @@ ftp.disconnect()

// Using AntBuilder; for more details, see:
// http://ant.apache.org/manual/OptionalTasks/ftp.html

ant = new AntBuilder()
ant.ftp(action:'send', server:'ftp.hypothetical.india.org', port:'2121',
remotedir:'/pub/incoming', userid:'coder', password:'java1',
Expand Down Expand Up @@ -893,7 +898,7 @@ writer.write( header.toString() )
// Write the body of the message
writer.write( "This is a test..." )

// Close the writer
// Close the writer
writer.close()
if ( !client.completePendingCommand() ) // failure
System.exit( 1 )
Expand Down Expand Up @@ -1872,7 +1877,7 @@ println URLEncoder.encode(/"this isn't <EASY>&<FUN>"/, 'utf-8')
// @@PLEAC@@_20.3
//----------------------------------------------------------------------------------
// using HtmlUnit (htmlunit.sf.net)
import com.gargoylesoftware.htmlunit.WebClient
//import com.gargoylesoftware.htmlunit.WebClient

client = new WebClient()
html = client.getPage('http://www.perl.com/CPAN/')
Expand Down Expand Up @@ -1945,7 +1950,6 @@ println html.titleText
// @@PLEAC@@_20.7
//----------------------------------------------------------------------------------
//import com.gargoylesoftware.htmlunit.WebClient
class WebClient{}

client = new WebClient()
page = client.getPage('http://www.perl.com/CPAN/')
Expand Down

0 comments on commit 0ae468c

Please sign in to comment.