您可能知道,SuppressFBWarnings
注释保留在类文件中,但在运行时不需要,因此FindBugs不会成为项目的运行时依赖项。不幸的是,对于使用该项目作为依赖项的Gradle用户来说,那些重新注释的注释会导致像这样的编译警告:
warning: Cannot find annotation method 'value()' in type
'SuppressFBWarnings': class file for
edu.umd.cs.findbugs.annotations.SuppressFBWarnings not found
请注意,Maven用户不会收到任何警告(使用默认的javac配置)。但我当然不能忽视Gradle用户。
所以我似乎必须以某种方式从发布版本中删除这些注释。但我无法找到任何现有的解决方案,这很奇怪。其他人如何处理这个问题?
答案 0 :(得分:1)
使用Gradle,您可以通过以下方式消除已发布Jars中的此类警告,
from turtle import Screen, Turtle
from random import randint
CURSOR_SIZE = 20
# create a new screen and set screen size
screen = Screen()
screen.screensize(500, 500)
screen.bgcolor("pink")
screen.title("Treasure hunt")
# create turtle and its shape
pepe = Turtle("turtle", visible=False)
pepe.color("blue")
pepe.penup()
pepe.setposition(randint(-250, 250), randint(-250, 250))
pepe.pendown()
pepe.showturtle()
# create turtle that draws treasure square, set in random position
pat = Turtle('square', visible=False)
pat.shapesize(30 / CURSOR_SIZE)
pat.color("black", "red")
pat.penup()
pat.setposition(randint(-250, 250), randint(-250, 250))
pat.showturtle()
# prompt user if they want to go on a treasure hunt
treasure_hunt = input("Do you want to go on a treasure hunt? Press y to continue: ")
while treasure_hunt == 'y':
# ask user for input to move their turtle, each time sets
# the angle back to 0 to move right and 90 to move up
left_or_right = int(input("Enter number between -250 and 250 to move left or right: "))
pepe.setheading(0)
pepe.forward(left_or_right)
up_or_down = int(input("Enter number between -250 and 250 to move up or down: "))
pepe.setheading(90)
pepe.forward(up_or_down)
if pepe.distance(pat) < 15:
pat.write("You did it!", font=("Arial", 16, "normal"))
break
screen.mainloop()