Mam kilka artefaktów z tego samego groupId (org.webjars
) i muszę rozpakować je, a następnie skopiować wszystkie zawarte pliki js do tego samego katalogu.Maven: Jak rozpakować dokładne pliki z artefaktów w tym samym katalogu wyjściowym?
Archiwa Artefakty mają hierarchię (skompresowany w słoiku) w następujący sposób:
artifact1
- resources
- webjars
- ...
- sample-1.js
- sample-2.js
muszę w końcu, że każdy js plik jest kopiowany do tego samego katalogu bez ich hierarchii, w następujący sposób:
outputDirectory
- sample-1.js
- sample-2.js
- ...
- sample-n.js
wynik mogę dotrzeć jest następujący:
outputDirectory
- artifact-1
- resources
- webjars
- ...
- sample-1.js
- sample-2.js
- ...
- artifact-m
- resources
- webjars
- ...
- sample-n.js
Dla tym celu użyłem maven-dependency-plugin
:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack org.webjars dependencies</id>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<configuration>
<includeGroupIds>org.webjars</includeGroupIds>
<includes>**/*.js</includes>
<outputDirectory>${project.build.directory}/static</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Czy istnieje magiczny opcja tej wtyczki, aby to zrobić, lub powinny Muszę innej wtyczki, aby zakończyć pracę?
EDIT: Oto rozwiązanie I wreszcie stosować:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>copy org.webjars dependency to jar</id>
<phase>package</phase>
<goals><goal>run</goal></goals>
<configuration>
<target>
<copy todir="${project.build.directory}/classes/static" flatten="true">
<fileset dir="${project.build.directory}/static">
<include name="**/*.js"/>
</fileset>
</copy>
</target>
</configuration>
</execution>
</executions>
</plugin>
<!-- Force the generation of the jar to be done after the javascript dependencies have been copied.
Note : This is a half solution, as the jar is generated twice: a first time before the javascript get copied, and
another one after. As a result, there is the correct jar, but after two creations... -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>Force the jar-plugin to be called after the javascripts dependencies have been copied to be embedded</id>
<phase>package</phase>
<goals><goal>jar</goal></goals>
</execution>
</executions>
</plugin>
1 rok później i Twoja odpowiedź jest nadal pomocna !! –
2 lata później i twoja odpowiedź nadal jest pomocna !! –
Możesz zmienić fazę wykonania wtyczki antrun, aby przygotować pakiet. Wtedy nie musisz ponownie tworzyć słoika. – David