如何在Travis CI中测试Java 8?

时间:2016-12-06 00:00:41

标签: java java-8 continuous-integration travis-ci

我正在尝试运行Travis CI测试。像这样:

language: java
jdk: oraclejdk8
sudo: false
script: mvn test 

它应该非常简单......但我得到了这个错误:

 diamond operator is not supported in -source 1.5
      (use -source 7 or higher to enable diamond operator)
 lambda expressions are not supported in -source 1.5
  (use -source 8 or higher to enable lambda expressions)

应该是Java 8吧? 如何配置Travis CI以运行Java 8而不是Java 5?

欢迎任何帮助!

修改

这是我的POM:

<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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>br.com.simplepass</groupId>
  <artifactId>mapPointManager</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>mapPointManager</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>3.5.2</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

2 个答案:

答案 0 :(得分:1)

您应该在pom脚本中添加以下标记:

M

这将使源和目标编译为java 1.8。 顺便说一下,我有一个使用Java 8和Travis的GitHub项目,你可以看看!你的整个pom都是这样的:

Set metaElements = html.all.tags("meta")

Dim brandFound As Boolean
Dim hElement As IHTMLElement
brandFound = False
For Each hElement In metaElements
    If InStr(1, hElement.outerHTML, "itemprop=" & Chr(34) & "brand" & Chr(34)) <> 0 Then
        Vendor = hElement.Content
        brandFound = True
    End If
    If brandFound = True Then
        If InStr(1, hElement.outerHTML, "itemprop=" & Chr(34) & "image" & Chr(34)) <> 0 Then
            Image = hElement.Content
            Exit For
        End If
    End If
Next hElement

答案 1 :(得分:0)

基于zapi评论,我改变了我的pom:

Dim lastRow As Long
lRows = (oWorkSheet.Cells(Rows.Count, 1).End(xlUp).Row)
Dim lastColumn As Long
lCols = (oWorkSheet.Cells(1, Columns.Count).End(xlToLeft).Column)
Dim sheet As Variant
With Sheets(sName)
  sheet = .Range(.Cells(1, 1), .Cells(lRows, lCols))
End With
ReDim nameCols(lCols) As String

现在Travis正在使用Java 8。