Maven custom encryption plugin

I translated Ant script into Maven 2 and I have this problem: Ant script uses a pretty simple java class to encrypt files this way:

<target name="encrypt">
    <java classname="DESEncrypter">
        <classpath>
            <pathelement path="...classpath for this thing..." />
        </classpath>
        <arg line="fileToEncrypt.properties fileEncrypted.properties" />
    </java>
</target>

This DESEncrypteris a compiled class, the source of which is not a project, which I am converting, but is used similarly in other projects. Maybe I need to create a maven plugin for reuse, but I don't want to do it now. My question is: in which directory do I put the class DESEncrypterand how to call it? Using exec: java plugin maybe? I do not think encrypter belongs to directories src, testor resources.

Obviously, I don't want to include the encrypter class in the final product, just encrypted files.

+3
3

: DESEncrypter ? exec: java ? , encrypter src, .

Maven AntRun Plugin. , :

+3

( exec: java antrun) GMaven, Groovy . , , pom - ( script). BTW: groovy: java .

(, , ):

<plugin>
    <groupId>org.codehaus.groovy.maven</groupId>
    <artifactId>gmaven-plugin</artifactId>
    <dependencies>
        <dependency>
            <groupId>your.library.com</groupId>
            <artifactId>your-library</artifactId>
            <version>1.2.3</version>
        </dependency>
    </dependencies>
    <executions>
        <execution>
            <phase>process-classes</phase>
            <!-- Or any other phase -->
            <goals>
                <goal>execute</goal>
            </goals>
            <configuration>
                <source><![CDATA[
                import com.encryption.*;
                new Encrypter().encrypt(
                    new File(project.build.outputDirectory, 
                                                    'fileToEncrypt.properties'),
                    new File(project.build.outputDirectory, 
                                                    'encryptedFile.properties')
                )
                ]]></source>
            </configuration>
        </execution>
    </executions>
</plugin>

( , , antrun exec: java )

+2

You might just want to use the AntRun plugin, it should allow you to execute anything from Ant with a minimal amount of fuss. You will need a dependency on the / jar class that you used, but providing it with the amount of test, or provided that it will not pack it into your final product.

+1
source

Source: https://habr.com/ru/post/1762328/


All Articles