Skip to content

Commit

Permalink
out-paulp-ing paulp by compiling under 2.8 and without warnings; adde…
Browse files Browse the repository at this point in the history
…d pom.xml
  • Loading branch information
alexy committed Nov 7, 2009
1 parent fcbafad commit d736e4b
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .gitignore
@@ -0,0 +1,4 @@
*.iml
*.ipr
*.iws
target-*
127 changes: 127 additions & 0 deletions pom.xml
@@ -0,0 +1,127 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>optional</groupId>
<artifactId>optional_${scala.version}</artifactId>
<name>optional</name>
<version>1.0</version>
<url>git://github.com/paulp/optional.git</url>
<organization>
<name>DR MacIver and Paul Phillips</name>
</organization>
<description>Java Command-Line Arguments</description>
<properties>
<java.src.version>1.6</java.src.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<profiles>
<profile>
<id>Scala-2.7.5</id>
<properties>
<scala.version>2.7.5</scala.version>
</properties>
</profile>
<profile>
<id>Scala-2.8.0-SNAPSHOT</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<scala.version>2.8.0-SNAPSHOT</scala.version>
</properties>
</profile>
</profiles>
<repositories>
<repository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Release Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</repository>
<repository>
<id>snapshots.scala-tools.org</id>
<name>Scala-Tools Maven2 Snapshot Repository</name>
<url>http://scala-tools.org/repo-snapshots</url>
<snapshots>
<enabled>true</enabled>
<!--updatePolicy>never</updatePolicy-->
<checksumPolicy>fail</checksumPolicy>
</snapshots>
<releases>
<enabled>true</enabled>
<!--updatePolicy>never</updatePolicy-->
<checksumPolicy>fail</checksumPolicy>
</releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>scala-tools.org</id>
<name>Scala-Tools Maven2 Repository</name>
<url>http://scala-tools.org/repo-releases</url>
</pluginRepository>
</pluginRepositories>
<dependencies>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-compiler</artifactId>
<version>${scala.version}</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.paranamer</groupId>
<artifactId>paranamer</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/scala</sourceDirectory>
<directory>target-${scala.version}</directory>
<resources>
<resource>
<directory>resources</directory>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
<configuration>
<args>
<arg>-deprecation</arg>
<arg>-unchecked</arg>
<arg>-optimise</arg>
</args>
<jvmArgs>
<jvmArg>-Xmx128m</jvmArg>
<jvmArg>-Xss2m</jvmArg>
<jvmArg>-Dfile.encoding=UTF-8</jvmArg>
</jvmArgs>
<excludes>
<exclude>**/draft/*.*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>compile</goal>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.scala-tools</groupId>
<artifactId>maven-scala-plugin</artifactId>
</plugin>
</plugins>
</reporting>
</project>
2 changes: 1 addition & 1 deletion src/main/scala/examples/hello.scala
Expand Up @@ -12,7 +12,7 @@ object Hello extends optional.Application
val _times = times getOrElse 1

println(
List.make(_times, _greeting).mkString(", ") +
List.fill(_times)(_greeting).mkString(", ") +
" and %s does %sexist.".format(file.getAbsolutePath, (if (file.exists) "" else "not "))
)
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/scala/examples/sgrep.scala
Expand Up @@ -2,6 +2,7 @@ package optional.examples

import scala.util.matching.Regex
import java.io.File
import optional.ArgInfo

object sgrep extends optional.Application
{
Expand All @@ -18,7 +19,8 @@ object sgrep extends optional.Application
// case insensitive if -i is given
val regex = if (i) ("""(?i)""" + arg1.toString).r else arg1

for (line <- io.Source.fromFile(arg2).getLines ; if cond(regex findFirstIn line))
for (line <- io.Source.fromFile(arg2).getLines()
; if cond(regex findFirstIn line))
print(line)
}
}

0 comments on commit d736e4b

Please sign in to comment.