當前位置: 首頁>>代碼示例>>Java>>正文


Java MavenProject.getVersion方法代碼示例

本文整理匯總了Java中org.apache.maven.project.MavenProject.getVersion方法的典型用法代碼示例。如果您正苦於以下問題:Java MavenProject.getVersion方法的具體用法?Java MavenProject.getVersion怎麽用?Java MavenProject.getVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.maven.project.MavenProject的用法示例。


在下文中一共展示了MavenProject.getVersion方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getVersion

import org.apache.maven.project.MavenProject; //導入方法依賴的package包/類
protected String getVersion ( final MavenProject project )
{
    getLog ().debug ( "Properties: " + project.getProperties () );

    if ( !project.getVersion ().endsWith ( "-SNAPSHOT" ) )
    {
        // project version is already qualified
        return project.getVersion ();
    }

    final String version = project.getProperties ().getProperty ( "qualifiedVersion" );
    if ( version != null )
    {
        // we do have a direct qualified version
        return version;
    }

    final String q = project.getProperties ().getProperty ( "buildQualifier" );
    final String v = project.getProperties ().getProperty ( "unqualifiedVersion" );

    if ( q == null || v == null )
    {
        throw new IllegalStateException ( String.format ( "Unable to find qualified version for: %s", project.getArtifactId () ) );
    }

    // just stick it together
    return v + "." + q;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:29,代碼來源:UpdateMojo.java

示例2: execute

import org.apache.maven.project.MavenProject; //導入方法依賴的package包/類
public void execute() throws MojoExecutionException {
    log = getLog();
    try {
        OakProperties properties = new OakProperties();
        dependencyArtifacts = "io.github.wanghuayao:maven-plugin-oaktree:" + properties.getVersion() + ":dependency-artifacts";

        filter = new ProcessingFilter(likePatten, hitePatten, deep);

        MavenProject mp = (MavenProject) this.getPluginContext().get("project");
        String mavenHomeStr = removeUnusedCharInPath(mavenHome.getPath());
        File mvnExecFile = new File(mavenHomeStr + "/bin/mvn");
        mvnExec = mvnExecFile.getPath();
        String os = System.getProperty("os.name");
        if (os.toLowerCase().startsWith("win")) {
            mvnExec = mvnExec + ".cmd";
            isWindwos = true;
        }

        File okaBaseDir = new File(outputDirectory, "oaktree");
        File okadependencyDir = new File(okaBaseDir, "dependency");
        if (!okadependencyDir.exists()) {
            okadependencyDir.mkdirs();
        }
        okadependencyOutputDir = okadependencyDir.getPath();

        ArtifactItem rootItem = new ArtifactItem(mp.getGroupId(), mp.getArtifactId(), mp.getPackaging(), mp.getVersion());

        File rootPom = mp.getFile();
        int startDeep = 2;
        for (Object obj : mp.getDependencyArtifacts()) {
            DefaultArtifact artifact = (DefaultArtifact) obj;
            ArtifactItem chieldern = ArtifactItem.valueOf(artifact);
            if (filter.isGoOnProcessing(chieldern, startDeep)) {
                calcDependancy(chieldern, startDeep);
                rootItem.addChildren(chieldern);
            }
        }



        FileWriter w = null;
        try {
            File okaFile = new File(okaBaseDir,"okatree.txt");
            if(okaFile.exists()) {
                okaFile.delete();
            }
            w = new FileWriter(okaFile);
            log.info("writing file :  " + okaFile.getPath());
            printArtifactItem(w, rootItem, "");
            log.info("writing complete.");
        }finally {
            StreamUtils.quiteClose(w);
        }
    } catch (Exception ex) {
        getLog().error(ex.getMessage(), ex);
        throw new MojoExecutionException(ex.getMessage(), ex);
    }
}
 
開發者ID:wanghuayao,項目名稱:maven-plugin-oaktree,代碼行數:59,代碼來源:CreateTreeMojo.java


注:本文中的org.apache.maven.project.MavenProject.getVersion方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。