Artifact definition (.idea/artifacts/*.xml) change when refresh gradle modules
已回答
Hi there,
I have a project with 3 gradle modules. In my project's artifact definition (.idea/artifacts/*.xml), whenever I refresh gradle modules, it changes the "name" property of element tag when I run the project on wildfly.
It changes from
<element id="archive" name="nts.uk.shr.com.jar">
<element id="module-output" name="nts.uk.shr.com_main" />
<element id="dir-copy" path="$PROJECT_DIR$/../UniversalK/nts.uk/uk.com/shr/nts.uk.shr.com/out/production/resources" />
</element>
to
<element id="archive" name="uk.com.shr-nts.uk.shr.com.jar">
<element id="module-output" name="nts.uk.shr.com_main" />
<element id="dir-copy" path="$PROJECT_DIR$/../UniversalK/nts.uk/uk.com/shr/nts.uk.shr.com/out/production/resources" />
</element>
It makes the project unable to run because the name of the jars unmatch with the jars in libs.
I don't know why this happend. Any ideas?
This is my first post and English isn't my first language. Please forgive me if I make any mistake.
Thanks in advance.
请先登录再写评论。
What IDE version do you use?
Do you change artifact manually? Note that in case of Gradle (and Maven) based projects IDE automatically creates artifact configuration, including the names, based on build.gradle file configuration.
Does it help if you refresh the project and leave artifact name as "uk.com.shr-nts.uk.shr.com.jar" and rebuild the project?
I'm using version 2017.3.5
I do change the artifact definition xml manually. I know that IDE automatically creates artifact configuration, including the names, based on build.gradle file configuration. But the problem is that the project will run successfully if I change the artifact name from origin "uk.com.shr-nts.uk.shr.com.jar" to "nts.uk.shr.com.jar".
Why do you need to change it?
Because if I leave artifact name as "uk.com.shr-nts.uk.shr.com.jar", rebuild and run the project, I will catch error:
I really don't know how to fix it. Changing artifact name is just a temporary solution.
Do you deploy the artifact built by IDE (Build | Build Artifacts...) using IDE Run/Debug Configuration or you use Gradle? What JDK do you use for development?
If you want to configure artifacts manually you should create a new artifact (or duplicate existing one) and give it different name (other than is created automatically by IDE).
I deploy the artifact built by IDE using IDE Run/Debug Configuration in Java 1.8 JDK.
Is it normal to use manually configured artifacts? Can I change build.gradle to change the way IDE create artifact?
>Is it normal to use manually configured artifacts?
Generally it is Ok, but you should remember that if you change the project structure (e.g. project dependencies) you will need then to make corresponding changes to such artifacts manually.
>Can I change build.gradle to change the way IDE create artifact?
Please consult Gradle's documentation, e.g. see https://stackoverflow.com/a/6774649/2000323.