-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WAR file to use final name #111
Comments
this might be a side effect of how the assembly plugin itself works, but i'm not sure. what happens if you create your own assembly descriptor, do you still see the same behavior? now that filtering has been fixed, a possible solution could be to create another packaged descriptor that supports a maven property to set the war name. <dependencySets>
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<includes>
<include>${project.groupId}:${project.artifactId}</include>
</includes>
<outputDirectory>.</outputDirectory>
<outputFileNameMapping>${war.final.name}</outputFileNameMapping>
</dependencySet>
</dependencySets> |
Thanks for the quick feedback. I don't think there even needs to be a separate property, just use the final name:
That would be a sensible implementation of the " If it'd work... surprisingly this leads to the same name as before: Here's an excerpt of my POM:
|
I have to correct myself. This:
Leads to a WAR file in the image called |
yeah - i'm not entirely sure that's going to work in the current setup. it looks like you can set have you tried adding this to the war plugin configuration? <configuration>
<warName>${project.artifactId}</warName>
</configuration> i use that along w/ an assembly descriptor that looks like this: <assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bin</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/usr/local/tomcat/webapps</outputDirectory>
<includes>
<include>*.war</include>
</includes>
</fileSet>
</fileSets>
<files>
<file>
<source>src/main/docker/app/startup.sh</source>
<outputDirectory>/usr/local/bin</outputDirectory>
<fileMode>0755</fileMode>
</file>
</files>
</assembly> and everything works as expected. |
I was feeling daring enough. There's unit test failures in
In both cases I have now |
The windows unit test failure are fixed (though not yet released). I'm trying to push out a snapshot release I will ping you when it's out so that you could try again. |
yeah - i'm on a mac so it's very possible it's a path issue - have to remember to account for that going forward. so i'm not sure using <fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/usr/local/tomcat/webapps</outputDirectory>
<includes>
<include>*.war</include>
</includes>
</fileSet>
</fileSets> where also - make sure you've done a rebuilt your code before trying to build the container so you're sure the artifacts are correct. |
@rhuss I'm not too worried about the tests passing on Windows, but thanks for following up so well! |
sorry, didn't made it today. I've planned to spend Friday some hours on integrating the pull requests. |
I don't think we'd want it to read I find the |
ok - i just spent some time trying different configurations and from what i can tell, it's not possible to achieve what you want using any of the current pre-packaged assembly descriptors. there is no way to change the final name of the archive the assembly plugin creates/copies when using a one thing we could do is change the <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>artifact</id>
<dependencySets>
<dependencySet>
<useProjectArtifact>true</useProjectArtifact>
<includes>
<include>${project.groupId}:${project.artifactId}</include>
</includes>
<outputFileNameMapping>${project.build.finalName}.${artifact.extension}</outputFileNameMapping>
</dependencySet>
</dependencySets>
</assembly> if you wanted to override final name of the artifact being created, you'd do this in your pom <build>
<finalName>some-app-name</finalName>
...
</build> and then you'd end up w/ the artifact you want in the docker container. if you don't want to alter the name of the artifact at that level and want to do it in the configuration of the plugin e.g: <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warName>${project.artifactId}</warName>
</configuration>
</plugin> then the only way to get that artifact into your docker container is to use a custom assembly descriptor like the one from my comment above. filtering should be working with the changes you pulled and so you could just change the <includes>
<include>${project.artifactId}.war</include>
</includes> and achieve your desired results. as for your question about the in the above example if i was just deploying the war, the assembly section of my pom would look like this: <assembly>
<basedir>/usr/local/tomcat/webapps</basedir>
<descriptorRef>artifact</descriptorRef>
</assembly> but b/c i need to deploy a startup script along side the war, i need to control where the files get placed using the assembly descriptor and so my |
- allow the 'project.final.buildName' to be overriden Signed-off-by: Jae Gangemi <jgangemi@gmail.com>
i just created a PR that allows the artifact name to be overridden as described above. could you give it a try? |
0.11.2 including the fix has been released and pushed to Maven central. You can directly reference it and check, whether it works for you. Please reopen the ticket, if there is still an issue. |
I think it works, thanks! |
Correct me if I'm wrong, but when using
<descriptorRef>artifact</descriptorRef>
for a<packaging>war</packaging>
project, I'm getting the following WAR file inside my container:I am setting final name as follows, during my build:
I had expected the following WAR file inside my container:
Since the WAR file name translates into the context path, this leads to unfortunate URLs such as:
Thanks for a great plugin.
The text was updated successfully, but these errors were encountered: