默认情况下,一次为配置文件执行两次Maven复制资源

时间:2018-10-07 16:22:17

标签: maven maven-profiles maven-resources-plugin

我有一个Maven项目,其中定义了一个基于profile的构建,其中包括一个自定义maven-resource-plugin的配置。

...
<profiles>
    <profile>
        <id>docker</id>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.1.0</version>
                    <executions>
                        <execution>
                            <id>resources</id>
                            <phase>generate-resources</phase>
                            <goals>
                                <goal>copy-resources</goal>
                            </goals>
                            <configuration>
                                <outputDirectory>${basedir}/target/classes</outputDirectory>
                                <resources>
                                    <resource>
                                        <directory>${basedir}/src/main/resources</directory>
                                        <filtering>false</filtering>
                                        <excludes>
                                            <exclude>log4j2*.xml</exclude>
                                            <exclude>docker/*</exclude>
                                        </excludes>
                                    </resource>
                                </resources>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>
</profiles>
...

现在,当我执行mvn compile -P docker时,我可以看到资源插件执行了两次。

  

INFO] --- maven-resources-plugin:3.1.0:copy-resources(资源)@ mma-access-management-auth-server ---

     

[INFO]使用'UTF-8'编码复制过滤的资源。

     

[INFO]复制2个资源

     

[INFO] --- maven-resources-plugin:3.1.0:resources(default-resources)@ mma-access-management-auth-server ---

     

[INFO]使用'UTF-8'编码复制过滤的资源。

     

[INFO]复制5个资源

这是对的吗?我是否真的必须排除默认构建的所有资源,以避免通过默认资源再次复制它们?

1 个答案:

答案 0 :(得分:1)

请勿将插件再次绑定到generate-resources阶段。 仅使用配置标签时,可以更改默认执行的配置。

@bot.command()
async def game(ctx):
await ctx.message.delete()
parrot = '<a:parrot:498460603300446238>'
slotspin = '<a:heartgif:498082283077500938>'
slots = [':blue_heart:', ':blue_heart:', ':blue_heart:', ':purple_heart:', ':heart:', ':yellow_heart:', ':green_heart:', ':green_heart:', ':green_heart:', ':green_heart:', ':green_heart:', ':green_heart:']
slot1 = slots[random.randint(0, 11)]
slot2 = slots[random.randint(0, 11)]
slot3 = slots[random.randint(0, 11)]
slot4 = slots[random.randint(0, 11)]
slot5 = slots[random.randint(0, 11)]
slot6 = slots[random.randint(0, 11)]
slot7 = slots[random.randint(0, 11)]
slot8 = slots[random.randint(0, 11)]
slot9 = slots[random.randint(0, 11)]
slot10 = slots[random.randint(0, 11)]
slot11 = slots[random.randint(0, 11)]
slot12 = slots[random.randint(0, 11)]
slot13 = slots[random.randint(0, 11)]
slot14 = slots[random.randint(0, 11)]
slot15 = slots[random.randint(0, 11)]
slot16 = slots[random.randint(0, 11)]
slot17 = slots[random.randint(0, 11)]
slot18 = slots[random.randint(0, 11)]
slot19 = slots[random.randint(0, 11)]
slot20 = slots[random.randint(0, 11)]
slot21 = slots[random.randint(0, 11)]
slot22 = slots[random.randint(0, 11)]
slot23 = slots[random.randint(0, 11)]
slot24 = slots[random.randint(0, 11)]
slot25 = slots[random.randint(0, 11)]

slotOutput = '| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n'.format(slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18, slot19, slot20, slot21, slot22, slot23, slot24, slot25)
slotOutput1 = '| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n'.format(slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin, slotspin,)
results0 = '| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n'.format(parrot, parrot, parrot, parrot, parrot, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18, slot19, slot20, slot21, slot22, slot23, slot24, slot25)
results1 = '| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n'.format(slot1, slot2, slot3, slot4, slot5, parrot, parrot, parrot, parrot, parrot, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18, slot19, slot20, slot21, slot22, slot23, slot24, slot25)
results2 = '| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n'.format(slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, parrot, parrot, parrot, parrot, parrot, slot16, slot17, slot18, slot19, slot20, slot21, slot22, slot23, slot24, slot25)
results3 = '| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n'.format(slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, parrot, parrot, parrot, parrot, parrot, slot21, slot22, slot23, slot24, slot25)
results4 = '| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n'.format(slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18, slot19, slot20, parrot, parrot, parrot, parrot, parrot)
results5 = '| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n'.format(parrot, slot2, slot3, slot4, slot5, parrot, slot7, slot8, slot9, slot10, parrot, slot12, slot13, slot14, slot15, parrot, slot17, slot18, slot19, slot20, parrot, slot22, slot23, slot24, slot25)
results6 = '| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n'.format(slot1, parrot, slot3, slot4, slot5, slot6, parrot, slot8, slot9, slot10, slot11, parrot, slot13, slot14, slot15, slot16, parrot, slot18, slot19, slot20, slot21, parrot, slot23, slot24, slot25)
results7 = '| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n'.format(slot1, slot2, parrot, slot4, slot5, slot6, slot7, parrot, slot9, slot10, slot11, slot12, parrot, slot14, slot15, slot16, slot17, parrot, slot19, slot20, slot21, slot22, parrot, slot24, slot25)
results8 = '| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n'.format(slot1, slot2, slot3, parrot, slot5, slot6, slot7, slot8, parrot, slot10, slot11, slot12, slot13, parrot, slot15, slot16, slot17, slot18, parrot, slot20, slot21, slot22, slot23, parrot, slot25)
results9 = '| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n'.format(slot1, slot2, slot3, slot4, parrot, slot6, slot7, slot8, slot9, parrot, slot11, slot12, slot13, slot14, parrot, slot16, slot17, slot18, slot19, parrot, slot21, slot22, slot23, slot24, parrot)
results10 = '| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n'.format(parrot, slot2, slot3, slot4, slot5, slot6, parrot, slot8, slot9, slot10, slot11, slot12, parrot, slot14, slot15, slot16, slot17, slot18, parrot, slot20, slot21, slot22, slot23, slot24, parrot)
results11 = '| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n'.format(slot1, slot2, slot3, slot4, parrot, slot6, slot7, slot8, parrot, slot10, slot11, slot12, parrot, slot14, slot15, slot16, parrot, slot18, slot19, slot20, parrot, slot22, slot23, slot24, slot25)

msg = await ctx.message.channel.send("{}\n {} Is Spinning".format(slotOutput1,ctx.message.author.mention))
await asyncio.sleep(2)
await msg.edit(content='| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n {} Is Spinning'.format(slot1, slotspin, slotspin, slotspin, slotspin, slot6, slotspin, slotspin, slotspin, slotspin, slot11, slotspin, slotspin, slotspin, slotspin, slot16, slotspin, slotspin, slotspin, slotspin, slot21, slotspin, slotspin, slotspin, slotspin, ctx.message.author.mention))
await asyncio.sleep(2)
await msg.edit(content='| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n {} Is Spinning'.format(slot1, slot2, slotspin, slotspin, slotspin, slot6, slot7, slotspin, slotspin, slotspin, slot11, slot12, slotspin, slotspin, slotspin, slot16, slot17, slotspin, slotspin, slotspin, slot21, slot22, slotspin, slotspin, slotspin, ctx.message.author.mention))
await asyncio.sleep(2)
await msg.edit(content='| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n {} Is Spinning'.format(slot1, slot2, slot3, slotspin, slotspin, slot6, slot7, slot8, slotspin, slotspin, slot11, slot12, slot13, slotspin, slotspin, slot16, slot17, slot18, slotspin, slotspin, slot21, slot22, slot23, slotspin, slotspin, ctx.message.author.mention))
await asyncio.sleep(2)
await msg.edit(content='| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n {} Is Spinning'.format(slot1, slot2, slot3, slot4, slotspin, slot6, slot7, slot8, slot9, slotspin, slot11, slot12, slot13, slot14, slotspin, slot16, slot17, slot18, slot19, slotspin, slot21, slot22, slot23, slot24, slotspin, ctx.message.author.mention))
await asyncio.sleep(2)
await msg.edit(content='| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n| {} | {} | {} | {} | {} |\n {} Is Spinning'.format(slot1, slot2, slot3, slot4, slot5, slot6, slot7, slot8, slot9, slot10, slot11, slot12, slot13, slot14, slot15, slot16, slot17, slot18, slot19, slot20, slot21, slot22, slot23, slot24, slot25, ctx.message.author.mention))

if slot1 == slot2 == slot3 == slot4 == slot5:
    #await ctx.message.channel.send( "{}\n {} You Won".format(slotOutput,ctx.message.author.mention),delete_after=5)
    await msg.edit(content="{}\n {} You Won".format(results0,ctx.message.author.mention),delete_after=3)
elif slot6 == slot7 == slot8 == slot9 == slot10:
    #await ctx.message.channel.send( "{}\n {} You Won".format(slotOutput,ctx.message.author.mention),delete_after=5)
    await msg.edit(content="{}\n {} You Won".format(results1,ctx.message.author.mention),delete_after=3)
elif slot11 == slot12 == slot13 == slot14 == slot15:
    #await ctx.message.channel.send( "{}\n {} You Won".format(slotOutput,ctx.message.author.mention),delete_after=5)
    await msg.edit(content="{}\n {} You Won".format(results2,ctx.message.author.mention),delete_after=3)
elif slot16 == slot17 == slot18 == slot19 == slot20:
    #await ctx.message.channel.send( "{}\n {} You Won".format(slotOutput,ctx.message.author.mention),delete_after=5)
    await msg.edit(content="{}\n {} You Won".format(results3,ctx.message.author.mention),delete_after=3)
elif slot21 == slot22 == slot23 == slot24 == slot25:
    #await ctx.message.channel.send( "{}\n {} You Won".format(slotOutput,ctx.message.author.mention),delete_after=5)
    await msg.edit(content="{}\n {} You Won".format(results4,ctx.message.author.mention),delete_after=3)
elif slot1 == slot6 == slot11 == slot16 == slot21:
    #await ctx.message.channel.send( "{}\n {} You Won".format(slotOutput,ctx.message.author.mention),delete_after=5)
    await msg.edit(content="{}\n {} You Won".format(results5,ctx.message.author.mention),delete_after=3)
elif slot2 == slot7 == slot12 == slot17 == slot22:
    #await ctx.message.channel.send( "{}\n {} You Won".format(slotOutput,ctx.message.author.mention),delete_after=5)
    await msg.edit(content="{}\n {} You Won".format(results6,ctx.message.author.mention),delete_after=3)
elif slot3 == slot8 == slot13 == slot18 == slot23:
    #await ctx.message.channel.send( "{}\n {} You Won".format(slotOutput,ctx.message.author.mention),delete_after=5)
    await msg.edit(content="{}\n {} You Won".format(results7,ctx.message.author.mention),delete_after=3)
elif slot4 == slot9 == slot14 == slot19 == slot24:
    #await ctx.message.channel.send( "{}\n {} You Won".format(slotOutput,ctx.message.author.mention),delete_after=5)
    await msg.edit(content="{}\n {} You Won".format(results8,ctx.message.author.mention),delete_after=3)
elif slot5 == slot10 == slot15 == slot20 == slot25:
    #await ctx.message.channel.send( "{}\n {} You Won".format(slotOutput,ctx.message.author.mention),delete_after=5)
    await msg.edit(content="{}\n {} You Won".format(results9,ctx.message.author.mention),delete_after=3)
elif slot1 == slot7 == slot13 == slot19 == slot25:
    #await ctx.message.channel.send( "{}\n {} You Won".format(slotOutput,ctx.message.author.mention),delete_after=5)
    await msg.edit(content="{}\n {} You Won".format(results10,ctx.message.author.mention),delete_after=3)
elif slot5 == slot9 == slot13 == slot17 == slot21:
    #await ctx.message.channel.send( "{}\n {} You Won".format(slotOutput,ctx.message.author.mention),delete_after=5)
    await msg.edit(content="{}\n {} You Won".format(results11,ctx.message.author.mention),delete_after=3)
else:
    #await ctx.message.channel.send("{}\n {} You Lost".format(slotOutput,ctx.message.author.mention),delete_after=5)
    await msg.edit(content="{}\n {} You Lost".format(slotOutput,ctx.message.author.mention),delete_after=3)